#__slots__

[ follow ]
Python
fromPythonmorsels
2 weeks ago

__slots__ for optimizing classes

__slots__ replaces per-instance __dict__ with fixed named slots, preventing dynamic attribute assignment and reducing memory and attribute lookup overhead.
#python
fromPythonmorsels
2 weeks ago
Python

__slots__ for optimizing classes

Using __slots__ removes the per-instance __dict__, restricts allowed attributes, and improves memory usage and attribute access speed.
fromRealpython
2 months ago
Python

Working With Python's .__dict__ Attribute Quiz - Real Python

Understanding Python's __dict__ attribute clarifies attribute storage, object attribute ownership, mappingproxy behavior, and the role of __slots__.
[ Load more ]