Author: Armin Rigo <[email protected]>
Branch:
Changeset: r79888:68b5a3425c05
Date: 2015-09-29 10:03 +0200
http://bitbucket.org/pypy/pypy/changeset/68b5a3425c05/
Log: Tweaks to reduce the number of checks with the JIT, notably in
'lst[a:]'.
diff --git a/pypy/objspace/std/sliceobject.py b/pypy/objspace/std/sliceobject.py
--- a/pypy/objspace/std/sliceobject.py
+++ b/pypy/objspace/std/sliceobject.py
@@ -5,6 +5,7 @@
from pypy.interpreter.error import OperationError
from pypy.interpreter.typedef import GetSetProperty, TypeDef
from rpython.rlib.objectmodel import specialize
+from rpython.rlib import jit
class W_SliceObject(W_Root):
@@ -234,10 +235,16 @@
assert length >= 0
if start < 0:
start = 0
+ # hack for the JIT, for slices with no end specified:
+ # this avoids the two comparisons that follow
+ if jit.isconstant(stop) and stop == sys.maxint:
+ return start, length
if stop < start:
stop = start
if stop > length:
stop = length
- if start > length:
+ if jit.isconstant(start) and start == 0:
+ pass # no need to do the following check here
+ elif start > length:
start = length
return start, stop
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit