Author: Armin Rigo <[email protected]>
Branch: py3.5
Changeset: r89872:2c9ea4e91032
Date: 2017-02-01 10:05 +0100
http://bitbucket.org/pypy/pypy/changeset/2c9ea4e91032/

Log:    make the JIT see through tup[i:j]

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
@@ -196,12 +196,20 @@
         items = self.tolist()
         length = len(items)
         start, stop, step, slicelength = w_index.indices4(space, length)
+        if step == 1:
+            subitems = items[start:stop]
+        else:
+            subitems = self._getslice_advanced(items, start, step, slicelength)
+        return space.newtuple(subitems)
+
+    @staticmethod
+    def _getslice_advanced(items, start, step, slicelength):
         assert slicelength >= 0
         subitems = [None] * slicelength
         for i in range(slicelength):
             subitems[i] = items[start]
             start += step
-        return space.newtuple(subitems)
+        return subitems
 
     def descr_getnewargs(self, space):
         return space.newtuple([space.newtuple(self.tolist())])
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to