Author: Alex Gaynor <[email protected]>
Branch: dynamic-specialized-tuple
Changeset: r54749:7dadce969c5e
Date: 2012-04-25 10:22 -0400
http://bitbucket.org/pypy/pypy/changeset/7dadce969c5e/

Log:    promote the shape for constant index lookups before we do anything
        with the shape, so it can be constant folded

diff --git a/pypy/objspace/std/tupleobject.py b/pypy/objspace/std/tupleobject.py
--- a/pypy/objspace/std/tupleobject.py
+++ b/pypy/objspace/std/tupleobject.py
@@ -46,14 +46,17 @@
     def getitems_copy(self, space):
         return self.tolist(space)[:]
 
+    def _promote_for_read(self, idx):
+        if jit.isconstant(idx):
+            jit.promote(self.tuplestorage.getshape())
+
     def length(self):
         return self.tuplestorage.getlength()
 
     def getitem(self, space, i):
         from pypy.objspace.std.tupletype import read_obj
 
-        if jit.isconstant(i):
-            jit.promote(self.tuplestorage.getshape())
+        self._promote_for_read(i)
         return read_obj(space, self.tuplestorage, i)
 
 registerimplementation(W_TupleObject)
@@ -64,6 +67,7 @@
 
 def getitem__Tuple_ANY(space, w_tuple, w_index):
     index = space.getindex_w(w_index, space.w_IndexError, "tuple index")
+    w_tuple._promote_for_read(index)
     if index < 0:
         index += w_tuple.length()
     if not (0 <= index < w_tuple.length()):
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to