What does __slots__ do in a class in Python?
Correct answer
C. Restricts attributes and saves memory by avoiding a per-instance __dict__
5 views
C. Restricts attributes and saves memory by avoiding a per-instance __dict__
5 views
__slots__ fixes the set of attributes, reducing memory use.
Asked in: Python Interview OOP
https://docs.python.org/3/tutorial/classes.htmlNot sure why the answer is C? Ask here and get an explanation.