[pypy-commit] pypy py3.5: make the JIT see through tup[i:j]
arigo
pypy.commits at gmail.com
Wed Feb 1 04:06:19 EST 2017
Author: Armin Rigo <arigo at tunes.org>
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())])
More information about the pypy-commit
mailing list