开发者

python: what's the point of adding`__dict__` to `__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__.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜