diff options
author | Raymond Hettinger <python@rcn.com> | 2011-04-20 20:08:40 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2011-04-20 20:08:40 (GMT) |
commit | 296d6d0cd697e4367fc2c9ed1ca08edacdc5dee9 (patch) | |
tree | ad0858da88e2d5b08349e93782c61e5c2a72ee6a /Lib | |
parent | db26dff560c5a5364676b3f0bf43814108d655af (diff) | |
parent | fc330aeb6f6968d1b843b47c8d7f36a708eb5b0c (diff) | |
download | cpython-296d6d0cd697e4367fc2c9ed1ca08edacdc5dee9.zip cpython-296d6d0cd697e4367fc2c9ed1ca08edacdc5dee9.tar.gz cpython-296d6d0cd697e4367fc2c9ed1ca08edacdc5dee9.tar.bz2 |
Minor text rearrangement.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/collections.py | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/Lib/collections.py b/Lib/collections.py index 77ba11b..580b11c 100644 --- a/Lib/collections.py +++ b/Lib/collections.py @@ -151,16 +151,6 @@ class OrderedDict(dict): link.next = first root.next = first.prev = link - 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,) - def __sizeof__(self): sizeof = _sys.getsizeof n = len(self) + 1 # number of links including root @@ -201,6 +191,16 @@ class OrderedDict(dict): return '%s()' % (self.__class__.__name__,) return '%s(%r)' % (self.__class__.__name__, list(self.items())) + 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,) + def copy(self): 'od.copy() -> a shallow copy of od' return self.__class__(self) |