Python __slots__ and object layout explained
Save memory using Python slots.
Python __slots__ are useful for saving memory when you have a large number of small objects whose attributes are known ahead of time. In this video we learn about __slots__, what slots actually are and how they work.
― mCoding with James Murphy (https://mcoding.io)
Source code: https://github.com/mCodingLLC/VideosSampleCode
Slots docs: https://docs.python.org/3/reference/datamodel.html#slots
Descriptor docs: https://docs.python.org/3/reference/datamodel.html#descriptors
SUPPORT ME ⭐
---------------------------------------------------
Patreon: https://patreon.com/mCoding
Paypal: https://www.paypal.com/donate/?hosted_button_id=VJY5SLZ8BJHEE
Other donations: https://mcoding.io/donate
Top patrons and donors: Jameson, Laura M, Dragos C, Vahnekie, John Martin, Casey G, Pieter G, Krisztian M, Sigmanificient
BE ACTIVE IN MY COMMUNITY 😄
---------------------------------------------------
Discord: https://discord.gg/Ye9yJtZQuN
Github: https://github.com/mCodingLLC/
Reddit: https://www.reddit.com/r/mCoding/
Facebook: https://www.facebook.com/james.mcoding
CHAPTERS
---------------------------------------------------
0:00 Intro
0:43 Normal class
1:53 Slots class
2:44 Why use slots
4:21 Slots are descriptors
5:45 What are slots
8:32 Inheritance
9:14 No metaclass slots
9:24 Using a dict slot
https://www.youtube.com/watch?v=Iwf17zsDAnY