4 ms·
One thing you can do as a user already today to reduce Python dynamism of classes is using __slots__: https://wiki.python.org/moin/UsingSlots https://wiki.pytho
by ux 3y ago
One thing you can do as a user already today to reduce Python dynamism of classes is using __slots__: https://wiki.python.org/moin/UsingSlots https://wiki.python.org/moin/UsingSlots. I enjoy this a lot, not only for the memory and access performance boost, but because it also makes the code more rigid (and thus more resilient to monkey code attacks).
- miohtama 3y agoYes, already using __slots__ heavily. Since Python 3.10 you can also do @dataclass(slots=True) Class MyClass: pass