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

Alex Gaynor alex.gaynor at gmail.com
Fri Jul 8 02:12:59 CEST 2011


On Thu, Jul 7, 2011 at 4:03 PM, Alexander Petrov <alexandervpetrov at gmail.com
> 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
>

I haven't dug into this too deeply to see where the slowness is, however if
you replace the setslice + repeat thingy with `for i in range(--that
expression--): primes[i] = False` it becomes significantly faster, PyPy is
10x faster, and ~2x faster the original CPython version (CPython is ~2x
slower when it's written this way).

Alex

-- 
"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/a9d3cbd7/attachment.html>


More information about the pypy-dev mailing list