Python я в прод не пускал, но эта штука звучит полезной и приятной.
In Python every class can have instance attributes. By default Python uses a dict to store an object’s instance attributes. This is really helpful as it allows setting arbitrary new attributes at runtime.
However, for small classes with known attributes it might be a bottleneck. The dict wastes a lot of RAM. Python can’t just allocate a static amount of memory at object creation to store all the attributes. Therefore it sucks a lot of RAM if you create a lot of objects (I am talking in thousands and millions). Still there is a way to circumvent this issue. It involves the usage of
slots to tell Python not to use a dict, and only allocate space for a fixed set of attributes. Here is an example with and without
slots:
https://book.pythontips.com/en/latest/__slots__magic.html