]> granicus.if.org Git - python/commitdiff
Now that __keys are fully hidden, switch the underlying structure
authorRaymond Hettinger <python@rcn.com>
Tue, 3 Mar 2009 22:42:48 +0000 (22:42 +0000)
committerRaymond Hettinger <python@rcn.com>
Tue, 3 Mar 2009 22:42:48 +0000 (22:42 +0000)
to deque() which futher reduces the temptation to index or resort.
Also, it is a bit faster for some cases.

Lib/collections.py

index a1e8ed975bf8de104a8b392f7e252423c803cec5..2b0de187684fe80970b4fc3e0681eb0c820631eb 100644 (file)
@@ -27,11 +27,11 @@ class OrderedDict(dict, MutableMapping):
         except AttributeError:
             # Note the underlying data structure for this class is likely to
             # change in the future.  Do not rely on it or access it directly.
-            self.__keys = []
+            self.__keys = deque()
         self.update(*args, **kwds)
 
     def clear(self):
-        del self.__keys[:]
+        self.__keys.clear()
         dict.clear(self)
 
     def __setitem__(self, key, value):