[pypy-issue] [issue891] reduce and filter aren't jitted. map isn't jitted for built-in functions

Justin Peel tracker at bugs.pypy.org
Mon Oct 3 07:44:43 CEST 2011


New submission from Justin Peel <peelpy at gmail.com>:

Map is not jitted for built-in functions.

$ pypy -m timeit -s "x = range(256)" "map(abs,x)"
10000 loops, best of 3: 27.1 usec per loop

$ pypy -m timeit -s "x = range(256); _abs = lambda y: abs(y)" "map(_abs, x)"
100000 loops, best of 3: 10.6 usec per loop

$ pypy -m timeit -s "x = range(256)" "[abs(y) for y in x]"
100000 loops, best of 3: 11 usec per loop

As you can see, passing non-built-in function that calls a built-in is jitted by 
map, but not by calling using the built-in function.

Filter and reduce are both not jitted at all.

$ pypy -m timeit -s "x = range(256); f = lambda x: x > 100" "filter(f, x)"
10000 loops, best of 3: 75.7 usec per loop

$ pypy -m timeit -s "x = range(256); f = lambda x: x > 100" "[y for y in x if 
f(y)]"
100000 loops, best of 3: 6.81 usec per loop

$ pypy -m timeit -s "x = range(256)" "reduce(max, x)"
10000 loops, best of 3: 49.9 usec per loop

$ python -m timeit -s "x = range(256)" "reduce(max, x)"
10000 loops, best of 3: 30 usec per loop

Notice that for filter I compared with a list expression equivalent (or nearly 
equivalent) while for reduce I just compared with CPython (2.7.1). 

We have a choice here: do we make these all jitted in RPython or do we want to 
make them app level?

----------
messages: 3225
nosy: justinpeel, pypy-issue
priority: feature
status: unread
title: reduce and filter aren't jitted. map isn't jitted for built-in functions

________________________________________
PyPy bug tracker <tracker at bugs.pypy.org>
<https://bugs.pypy.org/issue891>
________________________________________


More information about the pypy-issue mailing list