summaryrefslogtreecommitdiffstats
path: root/Lib/collections/__init__.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2013-05-21 09:47:57 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2013-05-21 09:47:57 (GMT)
commit3ee6dabf5b2bcfe5aa27a6db4f7adb7d7f33f8d6 (patch)
treead4d88662f6f20d28f16a6ee262a29a8d7ff62ad /Lib/collections/__init__.py
parentb10c71daa2099c450101e5854fd693a405bec49c (diff)
downloadcpython-3ee6dabf5b2bcfe5aa27a6db4f7adb7d7f33f8d6.zip
cpython-3ee6dabf5b2bcfe5aa27a6db4f7adb7d7f33f8d6.tar.gz
cpython-3ee6dabf5b2bcfe5aa27a6db4f7adb7d7f33f8d6.tar.bz2
Issue #17900: Allowed pickling of recursive OrderedDicts. Decreased pickled
size and pickling time.
Diffstat (limited to 'Lib/collections/__init__.py')
-rw-r--r--Lib/collections/__init__.py5
1 files changed, 1 insertions, 4 deletions
diff --git a/Lib/collections/__init__.py b/Lib/collections/__init__.py
index 5fd54e8..e1a075c 100644
--- a/Lib/collections/__init__.py
+++ b/Lib/collections/__init__.py
@@ -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'