[Python-checkins] cpython (2.7): Minor code simplification.
raymond.hettinger
python-checkins at python.org
Sun Apr 24 01:27:46 CEST 2011
http://hg.python.org/cpython/rev/d6729016eedc
changeset: 69536:d6729016eedc
branch: 2.7
user: Raymond Hettinger <python at rcn.com>
date: Sat Apr 23 15:51:38 2011 -0700
summary:
Minor code simplification.
files:
Lib/collections.py | 30 +++++++++++++++---------------
1 files changed, 15 insertions(+), 15 deletions(-)
diff --git a/Lib/collections.py b/Lib/collections.py
--- a/Lib/collections.py
+++ b/Lib/collections.py
@@ -65,9 +65,7 @@
# 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)
- link = self.__map.pop(key)
- link_prev = link[PREV]
- link_next = link[NEXT]
+ link_prev, link_next, key = self.__map.pop(key)
link_prev[NEXT] = link_next
link_next[PREV] = link_prev
@@ -132,18 +130,6 @@
__update = update # let subclasses override update without breaking __init__
- def viewkeys(self):
- "od.viewkeys() -> a set-like object providing a view on od's keys"
- return KeysView(self)
-
- def viewvalues(self):
- "od.viewvalues() -> an object providing a view on od's values"
- return ValuesView(self)
-
- def viewitems(self):
- "od.viewitems() -> a set-like object providing a view on od's items"
- return ItemsView(self)
-
__marker = object()
def pop(self, key, default=__marker):
@@ -224,6 +210,20 @@
'od.__ne__(y) <==> od!=y'
return not self == other
+ # -- the following methods support python 3.x style dictionary views --
+
+ def viewkeys(self):
+ "od.viewkeys() -> a set-like object providing a view on od's keys"
+ return KeysView(self)
+
+ def viewvalues(self):
+ "od.viewvalues() -> an object providing a view on od's values"
+ return ValuesView(self)
+
+ def viewitems(self):
+ "od.viewitems() -> a set-like object providing a view on od's items"
+ return ItemsView(self)
+
################################################################################
### namedtuple
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list