[pypy-dev] [pypy-svn] r77101 - in pypy/trunk/pypy: jit/tl module/__builtin__ module/__builtin__/test module/pypyjit/test

Antonio Cuni anto.cuni at gmail.com
Thu Sep 16 09:03:32 CEST 2010


Hi,

On 16/09/10 07:27, hakanardo at codespeak.net wrote:

> Log:
> Allow jit to unroll calls to max() and min() with more than one argument.
>
[cut]
> + at unroll_safe
>   @specialize.arg(2)
>   def min_max(space, args, implementation_of):
>       if implementation_of == "max":
>           compare = space.gt
>       else:
>           compare = space.lt
> +
> +    args_w = args.arguments_w
> +    if len(args_w)>  1 and not args.keywords: # Unrollable case
> +        w_max_item = None
> +        for w_item in args_w:
> +            if w_max_item is None or \
> +                   space.is_true(compare(w_item, w_max_item)):
> +                w_max_item = w_item
> +        return w_max_item
> +    else:
> +        return min_max_loop(space, args, implementation_of)


I don't think it's a good idea. What happens if I call max() over a list of 1 
million of elements? We obviously don't want the jit to unroll 1 million of 
iterations. Or am I missing something?

ciao,
Anto



More information about the Pypy-dev mailing list