Why not use __slots__ in python class? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 4

Why not use __slots__ in python class?

Python defaultly uses a dict to store the class instance values. Here we can change this by using the special variable __slots__. It increases the time efficiency of the class by 40-50%. So is there any reason not to use it, as I can see very rare usage of it in the classes? Especially the built-in ones.

4th Jan 2020, 5:30 PM
(^_^) 💤
(^_^) 💤 - avatar
0 Answers