This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author serhiy.storchaka
Recipients Mark.Shannon, lemburg, methane, rhettinger, serhiy.storchaka
Date 2021-09-23.12:50:08
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1632401408.39.0.102710647871.issue40116@roundup.psfhosted.org>
In-reply-to
Content
There are several common idioms which do not work well with shared dictionaries.

1. Class attributes as defaults. If most instances of the class have the default value for some attribute, it can be set as the class attribute. It saves memory because most instances will have smaller dict. But if the first instance has such attribute, it cancels shared dict for all following instances without this attribute.

2. cached_property (and analogs). The cached instance attributes can be added in arbitrary order, canceling shared dict for this instance and maybe for all instances created later.

3. Some classes delete attributes in close() or __exit__() methods to avoid reference loops and to release resources earlier. Since shared dicts do not support deletion, such closed objects have now larger size than non-closed objects.
History
Date User Action Args
2021-09-23 12:50:08serhiy.storchakasetrecipients: + serhiy.storchaka, lemburg, rhettinger, methane, Mark.Shannon
2021-09-23 12:50:08serhiy.storchakasetmessageid: <1632401408.39.0.102710647871.issue40116@roundup.psfhosted.org>
2021-09-23 12:50:08serhiy.storchakalinkissue40116 messages
2021-09-23 12:50:08serhiy.storchakacreate