Message235477
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). |
|
Date |
User |
Action |
Args |
2015-02-06 10:59:02 | serhiy.storchaka | set | recipients:
+ serhiy.storchaka, rhettinger, pitrou, alexandre.vassalotti, stutzbach |
2015-02-06 10:59:02 | serhiy.storchaka | set | messageid: <1423220342.09.0.607152258634.issue23401@psf.upfronthosting.co.za> |
2015-02-06 10:59:02 | serhiy.storchaka | link | issue23401 messages |
2015-02-06 10:59:01 | serhiy.storchaka | create | |
|