[pypy-svn] r25383 - pypy/dist/pypy/objspace

auc at codespeak.net auc at codespeak.net
Wed Apr 5 15:23:14 CEST 2006


Author: auc
Date: Wed Apr  5 15:23:13 2006
New Revision: 25383

Modified:
   pypy/dist/pypy/objspace/logic.py
Log:


Modified: pypy/dist/pypy/objspace/logic.py
==============================================================================
--- pypy/dist/pypy/objspace/logic.py	(original)
+++ pypy/dist/pypy/objspace/logic.py	Wed Apr  5 15:23:13 2006
@@ -579,16 +579,21 @@
 def unify__Root_Var(space, w_x, w_y):
     return space.unify(w_y, w_x)
 
-def unify__Tuple_Tuple(space, w_x, w_y):
-    return _unify_iterables(space, w_x, w_y)
+def unify__Tuple_Tuple(space, w_i1, w_i2):
+    if len(w_i1.wrappeditems) != len(w_i2.wrappeditems):
+        fail(space, w_i1, w_i2)
+    idx, top = (-1, space.int_w(space.len(w_i1))-1)
+    while idx < top:
+        idx += 1
+        w_xi = space.getitem(w_i1, space.newint(idx))
+        w_yi = space.getitem(w_i2, space.newint(idx))
+        if space.is_true(space.is_nb_(w_xi, w_yi)):
+            continue
+        unify(space, w_xi, w_yi)
+    return space.w_None
 
-def unify__List_List(space, w_x, w_y):
-    return _unify_iterables(space, w_x, w_y)
-    
-def _unify_iterables(space, w_i1, w_i2):
-    assert isinstance(w_i1, W_TupleObject) or isinstance(w_i1, W_ListObject)
-    assert isinstance(w_i2, W_TupleObject) or isinstance(w_i2, W_ListObject)
-    #print " :unify iterables", w_i1, w_i2
+
+def unify__List_List(space, w_i1, w_i2):
     if len(w_i1.wrappeditems) != len(w_i2.wrappeditems):
         fail(space, w_i1, w_i2)
     idx, top = (-1, space.int_w(space.len(w_i1))-1)
@@ -599,6 +604,12 @@
         if space.is_true(space.is_nb_(w_xi, w_yi)):
             continue
         unify(space, w_xi, w_yi)
+    return space.w_None
+    
+## def _unify_iterables(space, w_i1, w_i2):
+##     assert isinstance(w_i1, W_TupleObject) or isinstance(w_i1, W_ListObject)
+##     assert isinstance(w_i2, W_TupleObject) or isinstance(w_i2, W_ListObject)
+##     #print " :unify iterables", w_i1, w_i2
 
 def unify__Dict_Dict(space, w_m1, w_m2):
     assert isinstance(w_m1, W_DictObject)



More information about the Pypy-commit mailing list