[pypy-commit] pypy list-strategies: eliminated getitems() from compare methods in listobject

l.diekmann noreply at buildbot.pypy.org
Fri Sep 23 13:14:56 CEST 2011


Author: Lukas Diekmann <lukas.diekmann at uni-duesseldorf.de>
Branch: list-strategies
Changeset: r47527:42194b1eb02a
Date: 2011-08-30 15:22 +0200
http://bitbucket.org/pypy/pypy/changeset/42194b1eb02a/

Log:	eliminated getitems() from compare methods in listobject

diff --git a/pypy/objspace/std/listobject.py b/pypy/objspace/std/listobject.py
--- a/pypy/objspace/std/listobject.py
+++ b/pypy/objspace/std/listobject.py
@@ -933,39 +933,37 @@
         i += 1
     return space.w_True
 
-def lessthan_unwrappeditems(space, items1_w, items2_w):
+def lessthan_unwrappeditems(space, w_list1, w_list2):
     # needs to be safe against eq_w() mutating the w_lists behind our back
     # Search for the first index where items are different
     i = 0
-    while i < len(items1_w) and i < len(items2_w):
-        w_item1 = items1_w[i]
-        w_item2 = items2_w[i]
+    while i < w_list1.length() and i < w_list2.length():
+        w_item1 = w_list1.getitem(i)
+        w_item2 = w_list2.getitem(i)
         if not space.eq_w(w_item1, w_item2):
             return space.lt(w_item1, w_item2)
         i += 1
     # No more items to compare -- compare sizes
-    return space.newbool(len(items1_w) < len(items2_w))
+    return space.newbool(w_list1.length() < w_list2.length())
 
-def greaterthan_unwrappeditems(space, items1_w, items2_w):
+def greaterthan_unwrappeditems(space, w_list1, w_list2):
     # needs to be safe against eq_w() mutating the w_lists behind our back
     # Search for the first index where items are different
     i = 0
-    while i < len(items1_w) and i < len(items2_w):
-        w_item1 = items1_w[i]
-        w_item2 = items2_w[i]
+    while i < w_list1.length() and i < w_list2.length():
+        w_item1 = w_list1.getitem(i)
+        w_item2 = w_list2.getitem(i)
         if not space.eq_w(w_item1, w_item2):
             return space.gt(w_item1, w_item2)
         i += 1
     # No more items to compare -- compare sizes
-    return space.newbool(len(items1_w) > len(items2_w))
+    return space.newbool(w_list1.length() > w_list2.length())
 
 def lt__List_List(space, w_list1, w_list2):
-    return lessthan_unwrappeditems(space, w_list1.getitems(),
-        w_list2.getitems())
+    return lessthan_unwrappeditems(space, w_list1, w_list2)
 
 def gt__List_List(space, w_list1, w_list2):
-    return greaterthan_unwrappeditems(space, w_list1.getitems(),
-        w_list2.getitems())
+    return greaterthan_unwrappeditems(space, w_list1, w_list2)
 
 def delitem__List_ANY(space, w_list, w_idx):
     idx = get_list_index(space, w_idx)


More information about the pypy-commit mailing list