The whole point of __slots__
is to save space.
But I saw people add __dict__
to it so that new attributes can be added. Isn't this defeatin开发者_运维技巧g the goal of __slots__
?
Yes. If you want __dict__
, then just don't use __slots__
.
The whole point of __slots__
is to save space.
But I saw people add __dict__
to it so that new attributes can be added. Isn't this defeatin开发者_运维技巧g the goal of __slots__
?
Yes. If you want __dict__
, then just don't use __slots__
.
精彩评论