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 alexandre.vassalotti, pitrou, rhettinger, serhiy.storchaka, stutzbach
Date 2015-02-06.10:59:01
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1423220342.09.0.607152258634.issue23401@psf.upfronthosting.co.za>
In-reply-to
Content
There are many ways to pickle e.g. Mapping keys:

1) Default implementation (as an instances of Python class MappingKey). This is implementation depended and exposes private variable _mapping. Changing implementation of the keys() method will break compatibility.

2) As `self.__class__, (self._mapping,)`. It depends on implementation of keys() as MappingKey or MappingKey subclass. It doesn't very subclass friendly if keys() is more complex or MappingKey subclass requires additional parameters.

3) As `self._mapping.__class__.keys, (self._mapping,)`. Implementation agnostic, perhaps more efficient than option 4 because self._mapping.__class__.keys may be shared. But needs protocol 4.

4) As `self._mapping.keys, ()`. Implementation agnostic.

pickle_mapping_views.patch implements option 4, the patch in issue23264 implements option 3 (it works for dict with all protocols, but needs protocol 4 for dict subclasses). Perhaps implementations should be unified (use option 3 with protocol 4 and option 3 otherwise).
History
Date User Action Args
2015-02-06 10:59:02serhiy.storchakasetrecipients: + serhiy.storchaka, rhettinger, pitrou, alexandre.vassalotti, stutzbach
2015-02-06 10:59:02serhiy.storchakasetmessageid: <1423220342.09.0.607152258634.issue23401@psf.upfronthosting.co.za>
2015-02-06 10:59:02serhiy.storchakalinkissue23401 messages
2015-02-06 10:59:01serhiy.storchakacreate