mirror of
https://github.com/python/cpython.git
synced 2025-08-03 08:34:29 +00:00
Issue #17900: Allowed pickling of recursive OrderedDicts. Decreased pickled
size and pickling time.
This commit is contained in:
parent
b10c71daa2
commit
3ee6dabf5b
3 changed files with 15 additions and 6 deletions
|
@ -199,13 +199,10 @@ class OrderedDict(dict):
|
|||
|
||||
def __reduce__(self):
|
||||
'Return state information for pickling'
|
||||
items = [[k, self[k]] for k in self]
|
||||
inst_dict = vars(self).copy()
|
||||
for k in vars(OrderedDict()):
|
||||
inst_dict.pop(k, None)
|
||||
if inst_dict:
|
||||
return (self.__class__, (items,), inst_dict)
|
||||
return self.__class__, (items,)
|
||||
return self.__class__, (), inst_dict or None, None, iter(self.items())
|
||||
|
||||
def copy(self):
|
||||
'od.copy() -> a shallow copy of od'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue