#attribute-lookup

[ follow ]
Python
fromPythonmorsels
5 days 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
5 days ago

__slots__ for optimizing classes

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

Inside CPython's attribute lookup - Antonio Cuni's blog

Attribute lookup in Python is more complex than checking instance __dict__ then type; descriptors, instance vs type lookup, and metaclasses affect behavior.
[ Load more ]