How is __slots__ implemented in Python?
How is __slots__ implemented in Python? Is this exposed in the C interface ? How do I get __slots__ behaviour when defining a Python class in C via PyTypeObject ? When creating Python classes, they by default have a __dict__ and you can set any attribute on them. The point of slots is to not create a __dict__ to save space. In the C interface it's the other way around, an extension class has by default no __dict__ , and you would instead explicitly have to add one and add getattr/setattr support to handle it (although luckily there are methods for this already, PyObject_GenericGetAttr and