What are the trade-offs of using slots?
Properties, descriptors, and slots
Audio flashcard · 0:16Nortren·
What are the trade-offs of using slots?
0:16
Slots reduce memory overhead and speed up attribute access. The downsides are that you cannot add new attributes at runtime, weak references require explicit declaration, multiple inheritance with slots is restricted, and pickling can be more complex. Use slots when memory matters and dynamic attributes are not needed.
---
docs.python.org