[pypy-svn] r34789 - in pypy/dist/pypy/rpython: . lltypesystem test

arigo at codespeak.net arigo at codespeak.net
Mon Nov 20 14:04:57 CET 2006


Author: arigo
Date: Mon Nov 20 14:04:52 2006
New Revision: 34789

Modified:
   pypy/dist/pypy/rpython/lltypesystem/rtupletype.py
   pypy/dist/pypy/rpython/rtuple.py
   pypy/dist/pypy/rpython/test/test_rtuple.py
Log:
Forbit id() and 'is' between RPython tuples.  Add a hint that will
mean for the jit that we don't care about preserving the identity
of tuples.


Modified: pypy/dist/pypy/rpython/lltypesystem/rtupletype.py
==============================================================================
--- pypy/dist/pypy/rpython/lltypesystem/rtupletype.py	(original)
+++ pypy/dist/pypy/rpython/lltypesystem/rtupletype.py	Mon Nov 20 14:04:52 2006
@@ -10,5 +10,6 @@
         return Void      # empty tuple
     else:
         fields = [('item%d' % i, TYPE) for i, TYPE in enumerate(field_lltypes)]
-        kwds = {'hints': {'immutable': True}}
+        kwds = {'hints': {'immutable': True,
+                          'noidentity': True}}
         return Ptr(GcStruct('tuple%d' % len(field_lltypes), *fields, **kwds))

Modified: pypy/dist/pypy/rpython/rtuple.py
==============================================================================
--- pypy/dist/pypy/rpython/rtuple.py	(original)
+++ pypy/dist/pypy/rpython/rtuple.py	Mon Nov 20 14:04:52 2006
@@ -124,6 +124,9 @@
     def rtype_len(self, hop):
         return hop.inputconst(Signed, len(self.items_r))
 
+    def rtype_id(self, hop):
+        raise TyperError("cannot ask for the id() of a tuple")
+
     def get_ll_eq_function(self):
         return gen_eq_function(self.items_r)
 
@@ -218,7 +221,10 @@
                 items_v.append(item_v)
             return r_from.newtuple(llops, r_to, items_v)
         return NotImplemented
- 
+
+    def rtype_is_((robj1, robj2), hop):
+        raise TyperError("cannot compare tuples with 'is'")
+
 
 class AbstractTupleIteratorRepr(IteratorRepr):
 

Modified: pypy/dist/pypy/rpython/test/test_rtuple.py
==============================================================================
--- pypy/dist/pypy/rpython/test/test_rtuple.py	(original)
+++ pypy/dist/pypy/rpython/test/test_rtuple.py	Mon Nov 20 14:04:52 2006
@@ -106,11 +106,11 @@
             x = (n, 42)    # constant (5, 42) detected by the annotator
             y = (5, 42)    # another one, built by the flow space
             z = x + ()     # yet another
-            return id(x) == id(y) == id(z)
+            return x, y, z
         def f():
             return g(5)
         res = self.interpret(f, [])
-        assert res is True
+        assert res.item0 == res.item1 == res.item2
 
     def test_inst_tuple_getitem(self):
         class A:



More information about the Pypy-commit mailing list