MemotivaProperties, descriptors, and slots

What are slots?

Properties, descriptors, and slots

Audio flashcard · 0:16

Nortren·

What are slots?

0:16

Slots is a class attribute that restricts the attributes an instance can have. Defining slots replaces the default per-instance dict with a fixed-size structure, reducing memory usage and slightly speeding up attribute access. It is useful for classes with many instances, but it disables dynamic attribute addition.
docs.python.org