[issue40116] Regression in memory use of shared key dictionaries for "compact dicts"

Mark Shannon report at bugs.python.org
Mon Mar 30 11:39:15 EDT 2020


Mark Shannon <mark at hotpy.org> added the comment:

Just to clarify.

class AlwaysShared:

   opt = DEFAULT

   def __init__(self, attr, optional=None):
       self.attr = attr
       if optional:
           self.opt = optional

class SometimesShared:

   opt = DEFAULT

   def __init__(self, attr, optional=None):
       if optional:
           self.opt = optional
       self.attr = attr

The class AlwaysShared always has shared keys, whereas the class SometimesShared is not shared if `optional` is True for first instantiation, but False for a later instantiation.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue40116>
_______________________________________


More information about the Python-bugs-list mailing list