[pypy-issue] [issue892] Pypy is slower on longs than it should

Leonardo Santagada tracker at bugs.pypy.org
Mon Oct 3 19:41:55 CEST 2011


New submission from Leonardo Santagada <santagada at gmail.com>:

In Python Brasil this year we found that this code runs relatively the same on 
pypy and cpython on linux (and is much worse on osx):

fibs = {0: 0, 1: 1}
def fib(n):
    if n in fibs: return fibs[n]
    if n % 2 == 0:
        fibs[n] = ((2 * fib((n / 2) - 1)) + fib(n / 2)) * fib(n / 2)
    else:
        fibs[n] = (fib((n - 1) / 2) ** 2) + (fib((n + 1) / 2) ** 2)
    return fibs[n]

fib(10000000)

original by Henrique Pereira (implementation of a dijkstra algo) the link is 
here: https://gist.github.com/1256985

Alex Gaynor said that the reason is probably because pypy longs are known to be 
slower than cpythons.

----------
messages: 3239
nosy: pypy-issue, santagada
priority: bug
status: unread
title: Pypy is slower on longs than it should

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


More information about the pypy-issue mailing list