mirror of
https://github.com/python/cpython.git
synced 2025-08-01 23:53:15 +00:00
Separate initialization from clearing.
This commit is contained in:
parent
2f6f7436aa
commit
2dc90fdfaf
1 changed files with 4 additions and 3 deletions
|
@ -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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue