Python __slots__

Creator
Creator
Seonglae ChoSeonglae Cho
Created
Created
2024 Feb 29 4:22
Editor
Edited
Edited
2024 Feb 29 5:4
Refs
Refs
if a __slots__ list or tuple is defined, then a class will not have a __dict__ to store arbitrary values, thus saving memory. Instead, only the attributes defined in __slots__ can be set.
__slots__ are halfway between using a namedtuple and a regular class.
 
 
 
 
 
 

Recommendations