diff options
author | Raymond Hettinger <python@rcn.com> | 2009-03-25 22:41:32 +0000 |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2009-03-25 22:41:32 +0000 |
commit | 2dc90fdfaf79404ebbc91328af258b7895f86132 (patch) | |
tree | fc85abeca85c0f0027b85133625f555ca11deb57 | |
parent | 2f6f7436aa16df56b60e584f5396ffe7c608a2e1 (diff) | |
download | cpython-git-2dc90fdfaf79404ebbc91328af258b7895f86132.tar.gz |
Separate initialization from clearing.
-rw-r--r-- | Lib/collections.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/Lib/collections.py b/Lib/collections.py index da59608d3d..d77aff5a23 100644 --- a/Lib/collections.py +++ b/Lib/collections.py @@ -41,14 +41,15 @@ class OrderedDict(dict, MutableMapping): try: self.__root except AttributeError: - self.__root = _Link() # sentinel node for the doubly linked list - self.clear() + self.__root = root = _Link() # sentinel node for the doubly linked list + root.prev = root.next = root + self.__map = {} self.update(*args, **kwds) def clear(self): root = self.__root root.prev = root.next = root - self.__map = {} + self.__map.clear() dict.clear(self) def __setitem__(self, key, value): |