summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2009-03-25 22:45:22 (GMT)
committerRaymond Hettinger <python@rcn.com>2009-03-25 22:45:22 (GMT)
commit52dc06b23cea3c46cdfcfb4e420d4fddcaf29f61 (patch)
treec4dd2d0e1b4ec5dd89d666919fcedf438a5bb7a3
parent9611b5ef75446598b8fbd26016fa9cf20548291c (diff)
downloadcpython-52dc06b23cea3c46cdfcfb4e420d4fddcaf29f61.zip
cpython-52dc06b23cea3c46cdfcfb4e420d4fddcaf29f61.tar.gz
cpython-52dc06b23cea3c46cdfcfb4e420d4fddcaf29f61.tar.bz2
Separate initialization from clearing.
-rw-r--r--Lib/collections.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/Lib/collections.py b/Lib/collections.py
index 4f3f726..002ce97 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):