[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pypy-dev
Subject:    Re: [pypy-dev] PyPy is much slower than CPython example / question
From:       Alex Gaynor <alex.gaynor () gmail ! com>
Date:       2011-07-08 0:38:44
Message-ID: CAFRnB2VJdc1Gw4EviPmCQXXV8Jgv6fdDhAehFVZU5krxNWHb3g () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


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@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@python.org
> > http://mail.python.org/mailman/listinfo/pypy-dev
> _______________________________________________
> pypy-dev mailing list
> pypy-dev@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

[Attachment #5 (text/html)]

repeat itself is not slow, it&#39;s just that when it&#39;s used it iterates over it, \
in RPython (meaning it&#39;s not jit&#39;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&#39; thave that overhead.<div> <br></div><div>Alex<br><br><div \
class="gmail_quote">On Thu, Jul 7, 2011 at 5:30 PM, Romain Guillebert <span \
dir="ltr">&lt;<a href="mailto:romain.py@gmail.com">romain.py@gmail.com</a>&gt;</span> \
wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px \
#ccc solid;padding-left:1ex;"> Hi<br>
<br>
When I change this line:<br>
<br>
primes[i*i:N+1:i] = repeat(False, len(primes[i*i:N+1:i]))<br>
<br>
into this :<br>
<br>
primes[i*i:N+1:i] = [False] * len(primes[i*i:N+1:i])<br>
<br>
PyPy is much faster (but is still slower than CPython), so I would guess<br>
that the repeat function is the one to blame.<br>
<br>
Cheers<br>
<font color="#888888">Romain<br>
</font><div><div></div><div class="h5"><br>
On Fri, Jul 08, 2011 at 02:03:20AM +0300, Alexander Petrov wrote:<br>
&gt; Hi.<br>
&gt;<br>
&gt; I&#39;m new to PyPy and was trying to run some tests to see orders of<br>
&gt; speed improvement.<br>
&gt;<br>
&gt; Short script generating list of prime numbers using rather<br>
&gt; straightforward implementation of Eratosthene&#39;s sieve.<br>
&gt; Script: <a href="http://paste.pocoo.org/show/432727/" \
target="_blank">http://paste.pocoo.org/show/432727/</a><br> &gt;<br>
&gt; Typical results: <a href="http://paste.pocoo.org/show/432733/" \
target="_blank">http://paste.pocoo.org/show/432733/</a><br> &gt; (I thought that is \
due to absense of SSE2 on first computer, but I&#39;ve<br> &gt; rechecked on Intel(R) \
Xeon(R) CPU L5520 @ 2.27GHz with similar<br> &gt; results).<br>
&gt;<br>
&gt; I&#39;m getting that CPython is nearly 4-8 times faster than PyPy.<br>
&gt; Is it a bug in PyPy or what is wrong (may be &quot;specific&quot; to PyPy) in my \
script?<br> &gt;<br>
&gt; Alex.<br>
&gt; _______________________________________________<br>
&gt; pypy-dev mailing list<br>
&gt; <a href="mailto:pypy-dev@python.org">pypy-dev@python.org</a><br>
&gt; <a href="http://mail.python.org/mailman/listinfo/pypy-dev" \
target="_blank">http://mail.python.org/mailman/listinfo/pypy-dev</a><br> \
_______________________________________________<br> pypy-dev mailing list<br>
<a href="mailto:pypy-dev@python.org">pypy-dev@python.org</a><br>
<a href="http://mail.python.org/mailman/listinfo/pypy-dev" \
target="_blank">http://mail.python.org/mailman/listinfo/pypy-dev</a><br> \
</div></div></blockquote></div><br><br clear="all"><br>-- <br>&quot;I disapprove of \
what you say, but I will defend to the death your right to say it.&quot; -- Evelyn \
Beatrice Hall (summarizing Voltaire)<br>&quot;The people&#39;s good is the highest \
law.&quot; -- Cicero<br> <br>
</div>



_______________________________________________
pypy-dev mailing list
pypy-dev@python.org
http://mail.python.org/mailman/listinfo/pypy-dev


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic