[pypy-svn] r12289 - in pypy/dist/pypy: interpreter objspace/std objspace/std/test

pedronis at codespeak.net pedronis at codespeak.net
Sun May 15 15:29:33 CEST 2005


Author: pedronis
Date: Sun May 15 15:29:33 2005
New Revision: 12289

Modified:
   pypy/dist/pypy/interpreter/baseobjspace.py
   pypy/dist/pypy/objspace/std/dictobject.py
   pypy/dist/pypy/objspace/std/test/test_dictobject.py
Log:
let .eq_w shortcut through is_w. Use eq_w in dict lookup logic.



Modified: pypy/dist/pypy/interpreter/baseobjspace.py
==============================================================================
--- pypy/dist/pypy/interpreter/baseobjspace.py	(original)
+++ pypy/dist/pypy/interpreter/baseobjspace.py	Sun May 15 15:29:33 2005
@@ -171,7 +171,7 @@
 
     def eq_w(self, w_obj1, w_obj2):
         """shortcut for space.is_true(space.eq(w_obj1, w_obj2))"""
-        return self.is_true(self.eq(w_obj1, w_obj2))
+        return self.is_w(w_obj1, w_obj2) or self.is_true(self.eq(w_obj1, w_obj2))
 
     def is_w(self, w_obj1, w_obj2):
         """shortcut for space.is_true(space.is_(w_obj1, w_obj2))"""

Modified: pypy/dist/pypy/objspace/std/dictobject.py
==============================================================================
--- pypy/dist/pypy/objspace/std/dictobject.py	(original)
+++ pypy/dist/pypy/objspace/std/dictobject.py	Sun May 15 15:29:33 2005
@@ -70,14 +70,12 @@
         i = lookup_hash % len(self.data)
 
         entry = self.data[i]
-        if entry.w_key is None or \
-           space.is_true(space.is_(w_lookup, entry.w_key)):
+        if entry.w_key is None or space.is_w(w_lookup, entry.w_key):
             return entry
         if entry.w_key is self.w_dummy:
             freeslot = entry
         else:
-            if entry.hash == lookup_hash and space.is_true(
-                space.eq(entry.w_key, w_lookup)):
+            if entry.hash == lookup_hash and space.eq_w(entry.w_key, w_lookup):
                 return entry
             freeslot = None
 
@@ -91,8 +89,7 @@
                 else:
                     return entry
             if entry.hash == lookup_hash and entry.w_key is not self.w_dummy \
-                   and space.is_true(
-                space.eq(entry.w_key, w_lookup)):
+                   and space.eq_w(entry.w_key, w_lookup):
                 return entry
             if entry.w_key is self.w_dummy and freeslot is None:
                 freeslot = entry

Modified: pypy/dist/pypy/objspace/std/test/test_dictobject.py
==============================================================================
--- pypy/dist/pypy/objspace/std/test/test_dictobject.py	(original)
+++ pypy/dist/pypy/objspace/std/test/test_dictobject.py	Sun May 15 15:29:33 2005
@@ -322,8 +322,10 @@
         return x
     def is_(self, x, y):
         return x is y
+    is_w = is_
     def eq(self, x, y):
         return x == y
+    eq_w = eq
     def newlist(self, l):
         return []
 



More information about the Pypy-commit mailing list