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

Hakan Ardo hakan at debian.org
Thu Sep 16 09:18:57 CEST 2010


2010 at 9:03 AM, Antonio Cuni <anto.cuni at gmail.com> wrote:
>> +
>> +    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?

If lst is your list, the call max(lst) has a single argument, the
list, and it will be passed to the old implementation now called
min_max_loop. However if you call max(*lst) the jit will unroll it.
But why would you do that? The idea here was to optimize the case
max(i,0) where you typically only have a few arguments. Anyway, how
about calling min_max_loop() as soon as len(args_w)  > 10 to be on the
safe side?

-- 
Håkan Ardö



More information about the Pypy-dev mailing list