[pypy-dev] [pypy-commit] pypy default: add a few unrolls to tuple

Carl Friedrich Bolz cfbolz at gmx.de
Tue Mar 13 11:14:30 CET 2012


Hi Maciek,

I think this commit should come with corresponding pypy_c tests.

Cheers,

Carl Friedrich

On 03/12/2012 09:46 PM, fijal wrote:
> Author: Maciej Fijalkowski<fijall at gmail.com>
> Branch:
> Changeset: r53340:12f4497fa28c
> Date: 2012-03-12 13:46 -0700
> http://bitbucket.org/pypy/pypy/changeset/12f4497fa28c/
>
> Log:	add a few unrolls to tuple
>
> 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
> @@ -6,8 +6,8 @@
>   from pypy.rlib.rarithmetic import intmask
>   from pypy.objspace.std.sliceobject import W_SliceObject, normalize_simple_slice
>   from pypy.objspace.std import slicetype
> -from pypy.interpreter import gateway
>   from pypy.rlib.debug import make_sure_not_resized
> +from pypy.rlib import jit
>
>   class W_AbstractTupleObject(W_Object):
>       __slots__ = ()
> @@ -114,6 +114,9 @@
>   def mul__ANY_Tuple(space, w_times, w_tuple):
>       return mul_tuple_times(space, w_tuple, w_times)
>
> + at jit.look_inside_iff(lambda space, w_tuple1, w_tuple2:
> +                     jit.is_constant(len(w_tuple1.wrappeditems)) and
> +                     jit.is_constant(len(w_tuple2.wrappeditems)))
>   def eq__Tuple_Tuple(space, w_tuple1, w_tuple2):
>       items1 = w_tuple1.wrappeditems
>       items2 = w_tuple2.wrappeditems
> @@ -126,6 +129,9 @@
>               return space.w_False
>       return space.w_True
>
> + at jit.look_inside_iff(lambda space, w_tuple1, w_tuple2:
> +                     jit.is_constant(len(w_tuple1.wrappeditems)) and
> +                     jit.is_constant(len(w_tuple2.wrappeditems)))
>   def lt__Tuple_Tuple(space, w_tuple1, w_tuple2):
>       items1 = w_tuple1.wrappeditems
>       items2 = w_tuple2.wrappeditems
> @@ -137,6 +143,9 @@
>       # No more items to compare -- compare sizes
>       return space.newbool(len(items1)<  len(items2))
>
> + at jit.look_inside_iff(lambda space, w_tuple1, w_tuple2:
> +                     jit.is_constant(len(w_tuple1.wrappeditems)) and
> +                     jit.is_constant(len(w_tuple2.wrappeditems)))
>   def gt__Tuple_Tuple(space, w_tuple1, w_tuple2):
>       items1 = w_tuple1.wrappeditems
>       items2 = w_tuple2.wrappeditems
> @@ -161,6 +170,8 @@
>   def hash__Tuple(space, w_tuple):
>       return space.wrap(hash_tuple(space, w_tuple.wrappeditems))
>
> + at jit.look_inside_iff(lambda space, wrappeditems:
> +                     jit.is_constant(len(wrappeditems)))
>   def hash_tuple(space, wrappeditems):
>       # this is the CPython 2.4 algorithm (changed from 2.3)
>       mult = 1000003
> _______________________________________________
> pypy-commit mailing list
> pypy-commit at python.org
> http://mail.python.org/mailman/listinfo/pypy-commit



More information about the pypy-dev mailing list