From 2dc90fdfaf79404ebbc91328af258b7895f86132 Mon Sep 17 00:00:00 2001 From: Raymond Hettinger Date: Wed, 25 Mar 2009 22:41:32 +0000 Subject: [PATCH] Separate initialization from clearing. --- Lib/collections.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Lib/collections.py b/Lib/collections.py index da59608d3d4..d77aff5a238 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):