[pypy-svn] r79473 - in pypy/branch/rlist-jit/pypy: annotation objspace/std

arigo at codespeak.net arigo at codespeak.net
Wed Nov 24 16:43:19 CET 2010


Author: arigo
Date: Wed Nov 24 16:43:17 2010
New Revision: 79473

Modified:
   pypy/branch/rlist-jit/pypy/annotation/policy.py
   pypy/branch/rlist-jit/pypy/annotation/specialize.py
   pypy/branch/rlist-jit/pypy/objspace/std/objspace.py
   pypy/branch/rlist-jit/pypy/objspace/std/tupleobject.py
Log:
More reverts.  Now the idea is that lists with the 'must_not_mutate'
flag should not be present in general code, so space.newtuple() expects
a list *without* this flag.


Modified: pypy/branch/rlist-jit/pypy/annotation/policy.py
==============================================================================
--- pypy/branch/rlist-jit/pypy/annotation/policy.py	(original)
+++ pypy/branch/rlist-jit/pypy/annotation/policy.py	Wed Nov 24 16:43:17 2010
@@ -1,7 +1,6 @@
 # base annotation policy for specialization
 from pypy.annotation.specialize import default_specialize as default
 from pypy.annotation.specialize import specialize_argvalue, specialize_argtype, specialize_arglistitemtype
-from pypy.annotation.specialize import specialize_list_not_modified_any_more
 from pypy.annotation.specialize import memo
 # for some reason, model must be imported first,
 # or we create a cycle.
@@ -76,7 +75,6 @@
     specialize__arg = staticmethod(specialize_argvalue) # specialize:arg(N)
     specialize__argtype = staticmethod(specialize_argtype) # specialize:argtype(N)
     specialize__arglistitemtype = staticmethod(specialize_arglistitemtype)
-    specialize__list_not_modified_any_more = staticmethod(specialize_list_not_modified_any_more)
 
     def specialize__ll(pol, *args):
         from pypy.rpython.annlowlevel import LowLevelAnnotatorPolicy

Modified: pypy/branch/rlist-jit/pypy/annotation/specialize.py
==============================================================================
--- pypy/branch/rlist-jit/pypy/annotation/specialize.py	(original)
+++ pypy/branch/rlist-jit/pypy/annotation/specialize.py	Wed Nov 24 16:43:17 2010
@@ -369,8 +369,3 @@
     else:
         key = s.listdef.listitem.s_value.knowntype
     return maybe_star_args(funcdesc, key, args_s)
-    
-def specialize_list_not_modified_any_more(funcdesc, args_s, i):
-    s = args_s[i]
-    key = (s.knowntype is list and s.listdef.listitem.must_not_mutate)
-    return maybe_star_args(funcdesc, key, args_s)

Modified: pypy/branch/rlist-jit/pypy/objspace/std/objspace.py
==============================================================================
--- pypy/branch/rlist-jit/pypy/objspace/std/objspace.py	(original)
+++ pypy/branch/rlist-jit/pypy/objspace/std/objspace.py	Wed Nov 24 16:43:17 2010
@@ -266,8 +266,7 @@
 
     def newtuple(self, list_w):
         assert isinstance(list_w, list)
-        return W_TupleObject(list_not_modified_any_more(list_w))
-    newtuple._annspecialcase_ = 'specialize:list_not_modified_any_more(1)'
+        return W_TupleObject(list_not_modified_any_more(list_w)
 
     def newlist(self, list_w):
         return W_ListObject(list_w)

Modified: pypy/branch/rlist-jit/pypy/objspace/std/tupleobject.py
==============================================================================
--- pypy/branch/rlist-jit/pypy/objspace/std/tupleobject.py	(original)
+++ pypy/branch/rlist-jit/pypy/objspace/std/tupleobject.py	Wed Nov 24 16:43:17 2010
@@ -15,7 +15,8 @@
         w_self.wrappeditems = wrappeditems   # a list of wrapped values
         # Note that to make annotation happy with respect to
         # _immutable_fields_, wrappeditems must be a list known to
-        # be never mutated.  Use space.newtuple() if you are unsure.
+        # be never mutated.  Use space.newtuple() instead of directly
+        # calling this constructor.
 
     def __repr__(w_self):
         """ representation for debugging purposes """
@@ -61,7 +62,7 @@
 def getslice__Tuple_ANY_ANY(space, w_tuple, w_start, w_stop):
     length = len(w_tuple.wrappeditems)
     start, stop = normalize_simple_slice(space, length, w_start, w_stop)
-    return W_TupleObject(w_tuple.wrappeditems[start:stop])
+    return space.newtuple(w_tuple.wrappeditems[start:stop])
 
 def contains__Tuple_ANY(space, w_tuple, w_obj):
     for w_item in w_tuple.wrappeditems:
@@ -76,7 +77,7 @@
 def add__Tuple_Tuple(space, w_tuple1, w_tuple2):
     items1 = w_tuple1.wrappeditems
     items2 = w_tuple2.wrappeditems
-    return W_TupleObject(items1 + items2)
+    return space.newtuple(items1 + items2)
 
 def mul_tuple_times(space, w_tuple, w_times):
     try:
@@ -88,7 +89,7 @@
     if times == 1 and space.type(w_tuple) == space.w_tuple:
         return w_tuple
     items = w_tuple.wrappeditems
-    return W_TupleObject(items * times)    
+    return space.newtuple(items * times)    
 
 def mul__Tuple_ANY(space, w_tuple, w_times):
     return mul_tuple_times(space, w_tuple, w_times)



More information about the Pypy-commit mailing list