diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2013-05-21 09:47:57 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2013-05-21 09:47:57 (GMT) |
commit | 3ee6dabf5b2bcfe5aa27a6db4f7adb7d7f33f8d6 (patch) | |
tree | ad4d88662f6f20d28f16a6ee262a29a8d7ff62ad /Lib/collections/__init__.py | |
parent | b10c71daa2099c450101e5854fd693a405bec49c (diff) | |
download | cpython-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__.py | 5 |
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' |