[pypy-issue] [issue898] reduce() builtin appears to get no benefit from JIT; both jit, nojit versions 5x slower than CPython

Garen Parham tracker at bugs.pypy.org
Sun Oct 9 08:58:40 CEST 2011


New submission from Garen Parham <garen.p at gmail.com>:

While going through some scripts to test how fast pypy is, I came across this 
gem:

$ cat factorial_functional.py
import sys
from operator import mul

def factorial(n):
    return reduce(mul, xrange(1,n+1), 1)

if __name__ == '__main__':
    factorial(int(sys.argv[1]))


$ time /opt/python27/bin/python factorial_functional.py 100000

real    0m5.678s
user    0m5.346s
sys     0m0.329s

The the large number of 100000 was chosen to help amortize the JIT warmup cost, 
but when using pypy 1.6 or either of the 2011-10-09 nightlies of pypy-c-jit and 
pypy-c-nojit, all show about the same (much slower) performance--presumably due 
to calls to reduce() not being JIT'd:

$ time ~/dev/pypy-c-nojit-47882-3f96afe7cdc2-linux/bin/pypy 
factorial_functional.py 100000

real    0m25.985s
user    0m25.904s
sys     0m0.048s

$ time ~/dev/pypy-c-jit-47882-3f96afe7cdc2-linux/bin/pypy 
factorial_functional.py 100000


real    0m25.963s
user    0m25.827s
sys     0m0.118s

$ time ~/dev/pypy-1.6_32bit/bin/pypy factorial_functional.py 100000


real    0m26.139s
user    0m25.994s
sys     0m0.091s

----------
messages: 3271
nosy: Garen, pypy-issue
priority: bug
status: unread
title: reduce() builtin appears to get no benefit from JIT; both jit, nojit versions 5x slower than CPython

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


More information about the pypy-issue mailing list