[pypy-svn] r69806 - in pypy/trunk/pypy/jit/metainterp: . test

cfbolz at codespeak.net cfbolz at codespeak.net
Tue Dec 1 15:45:12 CET 2009


Author: cfbolz
Date: Tue Dec  1 15:45:12 2009
New Revision: 69806

Modified:
   pypy/trunk/pypy/jit/metainterp/optimizeutil.py
   pypy/trunk/pypy/jit/metainterp/test/test_optimizeopt.py
Log:
don't compare via sort_key here either, but just use the identity of the descrs


Modified: pypy/trunk/pypy/jit/metainterp/optimizeutil.py
==============================================================================
--- pypy/trunk/pypy/jit/metainterp/optimizeutil.py	(original)
+++ pypy/trunk/pypy/jit/metainterp/optimizeutil.py	Tue Dec  1 15:45:12 2009
@@ -1,4 +1,4 @@
-from pypy.rlib.objectmodel import r_dict
+from pypy.rlib.objectmodel import r_dict, compute_identity_hash
 from pypy.rlib.unroll import unrolling_iterable
 from pypy.jit.metainterp import resoperation
 
@@ -59,7 +59,7 @@
     mult = 1000003
     z = len(l)
     for descr in l:
-        y = descr.sort_key()
+        y = compute_identity_hash(descr)
         res = (res ^ y) * mult
         z -= 1
         mult += 82520 + z + z
@@ -70,7 +70,7 @@
     if len(l1) != len(l2):
         return False
     for i in range(len(l1)):
-        if l1[i].sort_key() != l2[i].sort_key():
+        if l1[i] is not l2[i]:
             return False
     return True
 

Modified: pypy/trunk/pypy/jit/metainterp/test/test_optimizeopt.py
==============================================================================
--- pypy/trunk/pypy/jit/metainterp/test/test_optimizeopt.py	(original)
+++ pypy/trunk/pypy/jit/metainterp/test/test_optimizeopt.py	Tue Dec  1 15:45:12 2009
@@ -119,6 +119,14 @@
     assert not optimizeutil.descrlist_eq([LLtypeMixin.nextdescr, LLtypeMixin.valuedescr],
                                          [LLtypeMixin.valuedescr, LLtypeMixin.nextdescr])
 
+    # descrlist_eq should compare by identity of the descrs, not by the result
+    # of sort_key
+    class FakeDescr(object):
+        def sort_key(self):
+            return 1
+
+    assert not optimizeutil.descrlist_eq([FakeDescr()], [FakeDescr()])
+
 
 # ____________________________________________________________
 



More information about the Pypy-commit mailing list