What are __slots__ and when are they useful?
Model answer
__slots__ declares a fixed set of attributes so instances do not carry a per-object dictionary, saving memory when you create very many objects. The trade-off is you cannot add arbitrary attributes. Measure before using it.
Learn this topic
The Python Standard Library: Dates, Counter, Statistics and More in the course Python for Beginners: Learn to Code with Real Projects.
Sign in to add your own answer.