开发者

python: what's the point of adding`__dict__` to `__slots__`

开发者 https://www.devze.com 2023-04-08 03:24 出处:网络
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 _

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__.

0

精彩评论

暂无评论...
验证码 换一张
取 消