If we only need objects where we access the original attributes and don’t need to add or remove attributes, we can create classes that don’t have a
__dict__. This is achieved simply by defining a class attribute called
__slots__ whose value is a tuple of attribute names. Each object of such a class will have attributes of the specified names and no
__dict__; no attributes can be added or removed from such classes. These objects consume less memory and are faster than conventional objects, although this is unlikely to make much difference unless large numbers of objects are created. If we inherit from a class that uses
__slots__ we must declare slots in our subcla...
- 8. Advanced Programming Techniques
- from Programming in Python 3: A Complete Introduction to the Python Language, Second Edition
- Publisher: Addison-Wesley Professional
- Released: November 2009
So slot is saying the memory layout is fixed, no need to keep record of change.
Share this highlighthttp://www.safaribooksonline.com/a/programming-in-python/9228233/