[pypy-commit] pypy set-strategies: what the hell did we do here!?

l.diekmann noreply at buildbot.pypy.org
Thu Nov 10 13:52:43 CET 2011


Author: Lukas Diekmann <lukas.diekmann at uni-duesseldorf.de>
Branch: set-strategies
Changeset: r49272:67ea580d5c56
Date: 2011-11-08 17:16 +0100
http://bitbucket.org/pypy/pypy/changeset/67ea580d5c56/

Log:	what the hell did we do here!?

diff --git a/pypy/objspace/std/setobject.py b/pypy/objspace/std/setobject.py
--- a/pypy/objspace/std/setobject.py
+++ b/pypy/objspace/std/setobject.py
@@ -1214,7 +1214,7 @@
     others_w.append(w_left)
 
     # find smallest set in others_w to reduce comparisons
-    startindex, startlength = -1, -1
+    startindex, startlength = 0, -1
     for i in range(len(others_w)):
         w_other = others_w[i]
         try:
@@ -1224,11 +1224,11 @@
                 raise
             continue
 
-        if length < startlength:
+        if startlength == -1 or length < startlength:
             startindex = i
             startlength = length
 
-    others_w[i], others_w[0] = others_w[0], others_w[i]
+    others_w[startindex], others_w[0] = others_w[0], others_w[startindex]
 
     result = w_left._newobj(space, others_w[0])
     for i in range(1,len(others_w)):
diff --git a/pypy/objspace/std/test/test_setobject.py b/pypy/objspace/std/test/test_setobject.py
--- a/pypy/objspace/std/test/test_setobject.py
+++ b/pypy/objspace/std/test/test_setobject.py
@@ -74,7 +74,11 @@
 
         d = W_SetObject(self.space)
         _initialize_set(self.space, d, self.space.wrap("ab"))
-        d.intersect = None
+
+        # if ordering works correct we should start with set e
+        a.get_storage_copy = None
+        b.get_storage_copy = None
+        d.get_storage_copy = None
 
         result = set_intersection__Set(space, a, [d,c,b])
         assert space.is_true(self.space.eq(result, W_SetObject(space, self.space.wrap(""))))


More information about the pypy-commit mailing list