https://docs.python.org/3/reference/datamodel.html
__init__: constructor__del__: destructor ?? (use with care)__delete__:__new__: this is called before__init____get__: read attribute value__set__: write attribute value__getattr__:__getattribute__:__setattr__:__delattr__:__getitem__: used when reading fromx[i]__setitem__: used when writing tox[i]__delitem__: used when deleting__missing__:__repr__: representation of object as a string__str__: human readable representation of object as string__lt__, -__gt__, -__le__, -__ge__, -__eq__, -__ne__: comparison__format__: used byformat()function (and f-strings)__hash__: used byhash()__bytes__: used bybytes()__bool__: used bybool()__iter__: used byiter()iterator.__next__():__reversed__:__contains__:__dir__: used bydir()__call__:__len__:__length_hint__:__enter__: enter context manager__exit__: leave context manager__objclass__:__slots__:__init_subclass__:__set_name__:__prepare__:__mro_entries__:__classcell__: CPython specific__class__:__instancecheck__:__subclasscheck__:__class_getitem__:__match_args__:__complex__:__int__:__float__:__index__:__round__:__trunc__:__floor__:__ceil__:__buffer__:__release_buffer__:__await__:__aiter__:__anext__:
__slot__
- Classes with slots does not have
__dict__(but their instances might??).- Saves space.
- Faster attribute access
- Remark: dataclass has a
slotsoption
See: