[pypy-commit] pypy default: unroll contains__Tuple in case we know the length (tuples are immutable)
fijal
noreply at buildbot.pypy.org
Sun Feb 3 13:32:19 CET 2013
Author: Maciej Fijalkowski <fijall at gmail.com>
Branch:
Changeset: r60836:c915d5e1101c
Date: 2013-02-03 14:31 +0200
http://bitbucket.org/pypy/pypy/changeset/c915d5e1101c/
Log: unroll contains__Tuple in case we know the length (tuples are
immutable)
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
@@ -85,6 +85,15 @@
start, stop = normalize_simple_slice(space, length, w_start, w_stop)
return space.newtuple(w_tuple.wrappeditems[start:stop])
+THRESHOLD = 7
+
+def unroll_tuple_contains(space, w_tuple, w_obj):
+ if (jit.isconstant(w_tuple) or jit.isvirtual(w_tuple) and
+ len(w_tuple.wrappeditems) < THRESHOLD):
+ return True
+ return False
+
+ at jit.look_inside_iff(unroll_tuple_contains)
def contains__Tuple_ANY(space, w_tuple, w_obj):
for w_item in w_tuple.wrappeditems:
if space.eq_w(w_item, w_obj):
More information about the pypy-commit
mailing list