[pypy-dev] PyPy is much slower than CPython example / question

Alex Gaynor alex.gaynor at gmail.com
Fri Jul 8 02:38:44 CEST 2011


repeat itself is not slow, it's just that when it's used it iterates over
it, in RPython (meaning it's not jit'd) which results in a dictionary lookup
for the next() method at every iteration, which is slowish, list hits a
special case so it doesn' thave that overhead.

Alex

On Thu, Jul 7, 2011 at 5:30 PM, Romain Guillebert <romain.py at gmail.com>wrote:

> Hi
>
> When I change this line:
>
> primes[i*i:N+1:i] = repeat(False, len(primes[i*i:N+1:i]))
>
> into this :
>
> primes[i*i:N+1:i] = [False] * len(primes[i*i:N+1:i])
>
> PyPy is much faster (but is still slower than CPython), so I would guess
> that the repeat function is the one to blame.
>
> Cheers
> Romain
>
> On Fri, Jul 08, 2011 at 02:03:20AM +0300, Alexander Petrov wrote:
> > Hi.
> >
> > I'm new to PyPy and was trying to run some tests to see orders of
> > speed improvement.
> >
> > Short script generating list of prime numbers using rather
> > straightforward implementation of Eratosthene's sieve.
> > Script: http://paste.pocoo.org/show/432727/
> >
> > Typical results: http://paste.pocoo.org/show/432733/
> > (I thought that is due to absense of SSE2 on first computer, but I've
> > rechecked on Intel(R) Xeon(R) CPU L5520 @ 2.27GHz with similar
> > results).
> >
> > I'm getting that CPython is nearly 4-8 times faster than PyPy.
> > Is it a bug in PyPy or what is wrong (may be "specific" to PyPy) in my
> script?
> >
> > Alex.
> > _______________________________________________
> > pypy-dev mailing list
> > pypy-dev at python.org
> > http://mail.python.org/mailman/listinfo/pypy-dev
> _______________________________________________
> pypy-dev mailing list
> pypy-dev at python.org
> http://mail.python.org/mailman/listinfo/pypy-dev
>



-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." -- Evelyn Beatrice Hall (summarizing Voltaire)
"The people's good is the highest law." -- Cicero
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pypy-dev/attachments/20110707/ccf718b6/attachment.html>


More information about the pypy-dev mailing list