[Python-checkins] r78814 - python/trunk/Lib/collections.py
raymond.hettinger
python-checkins at python.org
Tue Mar 9 12:29:10 CET 2010
Author: raymond.hettinger
Date: Tue Mar 9 12:29:10 2010
New Revision: 78814
Log:
Improve code clarity a bit.
Modified:
python/trunk/Lib/collections.py
Modified: python/trunk/Lib/collections.py
==============================================================================
--- python/trunk/Lib/collections.py (original)
+++ python/trunk/Lib/collections.py Tue Mar 9 12:29:10 2010
@@ -41,7 +41,8 @@
self.__root
except AttributeError:
self.__root = root = [None, None, None] # sentinel node
- PREV, NEXT = 0, 1
+ PREV = 0
+ NEXT = 1
root[PREV] = root[NEXT] = root
self.__map = {}
self.update(*args, **kwds)
@@ -51,7 +52,8 @@
# Setting a new item creates a new link which goes at the end of the linked
# list, and the inherited dictionary is updated with the new key/value pair.
if key not in self:
- PREV, NEXT = 0, 1
+ PREV = 0
+ NEXT = 1
root = self.__root
last = root[PREV]
last[NEXT] = root[PREV] = self.__map[key] = [last, root, key]
@@ -62,7 +64,8 @@
# Deleting an existing item uses self.__map to find the link which is
# then removed by updating the links in the predecessor and successor nodes.
dict.__delitem__(self, key)
- PREV, NEXT = 0, 1
+ PREV = 0
+ NEXT = 1
link = self.__map.pop(key)
link[PREV][NEXT] = link[NEXT]
link[NEXT][PREV] = link[PREV]
@@ -70,7 +73,8 @@
def __iter__(self):
'od.__iter__() <==> iter(od)'
# Traverse the linked list in order.
- NEXT, KEY = 1, 2
+ NEXT = 1
+ KEY = 2
root = self.__root
curr = root[NEXT]
while curr is not root:
@@ -80,7 +84,8 @@
def __reversed__(self):
'od.__reversed__() <==> reversed(od)'
# Traverse the linked list in reverse order.
- PREV, KEY = 0, 2
+ PREV = 0
+ KEY = 2
root = self.__root
curr = root[PREV]
while curr is not root:
More information about the Python-checkins
mailing list