Should You Use Slots? How Slots Affect Your Class, and When and How to Use Them

One line of code for a 20% performance increase?

Mike Huls
Towards Data Science
6 min readAug 12, 2023

--

(image by Sébastien Goldberg on Unsplash)

Slots are a mechanism that allow you to declare class attributes and restrict the creation of other attributes. You establish which attributes your class has, preventing developers from adding new attributes dynamically. This generally leads to a 20%

--

--