Hi, I've been recently doing Project Euler puzzles using Python, and have recently started to use PyPy to increase performance. However I've come across something (no pun intended) puzzling. I made this script for Euler #50. http://pastebin.com/VZ12Nsci It calculates all the primes under 1M first, then looks through them for a solution. The first part (finding primes) is blazing fast under PyPy (as expected). But in the second part PyPy lags behind. CPython managed it in 183s, while PyPy did it in 498s. I'm assuming it has something to do with the list slicing?
On 20/05/11 23:23, Mohyiddeen Othman wrote:
Hi,
I've been recently doing Project Euler puzzles using Python, and have recently started to use PyPy to increase performance. However I've come across something (no pun intended) puzzling. I made this script for Euler #50.
It calculates all the primes under 1M first, then looks through them for a solution. The first part (finding primes) is blazing fast under PyPy (as expected). But in the second part PyPy lags behind. CPython managed it in 183s, while PyPy did it in 498s. I'm assuming it has something to do with the list slicing?
I cannot reproduce, for me pypy is faster on both pieces of code: viper ~ $ pypyc /tmp/euler.py ('All primes below', 1000000, 'found') 0.43 Max sequence is: .... .... ('It contains', 543, 'elements') ('The sum is', 997651) 72.61 viper ~ $ python /tmp/euler.py ('All primes below', 1000000, 'found') 4.58 Max sequence is: .... .... ('It contains', 543, 'elements') ('The sum is', 997651) 128.81 Could you tell us more about your environment, like which OS, cpu, 32/64 bit and the exact version of pypy/cpython you used to do the benchmark please? ciao, Anto
Anto: what version of python did you use? There can be 2.6 vs 2.7 issue On Mon, May 23, 2011 at 10:11 AM, Antonio Cuni <anto.cuni@gmail.com> wrote:
On 20/05/11 23:23, Mohyiddeen Othman wrote:
Hi,
I've been recently doing Project Euler puzzles using Python, and have recently started to use PyPy to increase performance. However I've come across something (no pun intended) puzzling. I made this script for Euler #50.
It calculates all the primes under 1M first, then looks through them for a solution. The first part (finding primes) is blazing fast under PyPy (as expected). But in the second part PyPy lags behind. CPython managed it in 183s, while PyPy did it in 498s. I'm assuming it has something to do with the list slicing?
I cannot reproduce, for me pypy is faster on both pieces of code:
viper ~ $ pypyc /tmp/euler.py ('All primes below', 1000000, 'found') 0.43 Max sequence is: .... .... ('It contains', 543, 'elements') ('The sum is', 997651) 72.61
viper ~ $ python /tmp/euler.py ('All primes below', 1000000, 'found') 4.58 Max sequence is: .... .... ('It contains', 543, 'elements') ('The sum is', 997651) 128.81
Could you tell us more about your environment, like which OS, cpu, 32/64 bit and the exact version of pypy/cpython you used to do the benchmark please?
ciao, Anto _______________________________________________ pypydev mailing list pypydev@python.org http://mail.python.org/mailman/listinfo/pypydev
On 31/05/11 09:13, Maciej Fijalkowski wrote:
Anto: what version of python did you use? There can be 2.6 vs 2.7 issue
please don't do top posting, it's very confusing on mailing lists :( Anyway, the results below are with python2.7. python2.6 is slightly slower, but not much. I confirm that pypy is faster on my machine. ciao, Anto
On Mon, May 23, 2011 at 10:11 AM, Antonio Cuni <anto.cuni@gmail.com> wrote:
On 20/05/11 23:23, Mohyiddeen Othman wrote:
Hi,
I've been recently doing Project Euler puzzles using Python, and have recently started to use PyPy to increase performance. However I've come across something (no pun intended) puzzling. I made this script for Euler #50.
It calculates all the primes under 1M first, then looks through them for a solution. The first part (finding primes) is blazing fast under PyPy (as expected). But in the second part PyPy lags behind. CPython managed it in 183s, while PyPy did it in 498s. I'm assuming it has something to do with the list slicing?
I cannot reproduce, for me pypy is faster on both pieces of code:
viper ~ $ pypyc /tmp/euler.py ('All primes below', 1000000, 'found') 0.43 Max sequence is: .... .... ('It contains', 543, 'elements') ('The sum is', 997651) 72.61
viper ~ $ python /tmp/euler.py ('All primes below', 1000000, 'found') 4.58 Max sequence is: .... .... ('It contains', 543, 'elements') ('The sum is', 997651) 128.81
Could you tell us more about your environment, like which OS, cpu, 32/64 bit and the exact version of pypy/cpython you used to do the benchmark please?
ciao, Anto _______________________________________________ pypydev mailing list pypydev@python.org http://mail.python.org/mailman/listinfo/pypydev
I thought I did reply? Must've been mistaken. My bad. Thanks for the reply. I'm running Windows XP (32bit) on an Intel Core2Duo E6550 2.33 GHz. I'm using CPython 2.7 and PyPy 1.5 I'm begining to think I'm doing something wrong.  On Tue, 5/31/11, Antonio Cuni <anto.cuni@gmail.com> wrote: From: Antonio Cuni <anto.cuni@gmail.com> Subject: Re: [pypydev] List Slicing Performance Drop To: "Maciej Fijalkowski" <fijall@gmail.com> Cc: "Mohyiddeen Othman" <mohyiddeen@yahoo.com>, pypydev@python.org Date: Tuesday, May 31, 2011, 1:07 AM On 31/05/11 09:13, Maciej Fijalkowski wrote:
Anto: what version of python did you use? There can be 2.6 vs 2.7 issue
please don't do top posting, it's very confusing on mailing lists :( Anyway, the results below are with python2.7. python2.6 is slightly slower, but not much. I confirm that pypy is faster on my machine. ciao, Anto
On Mon, May 23, 2011 at 10:11 AM, Antonio Cuni <anto.cuni@gmail.com> wrote:
On 20/05/11 23:23, Mohyiddeen Othman wrote:
Hi,
I've been recently doing Project Euler puzzles using Python, and have recently started to use PyPy to increase performance. However I've come across something (no pun intended) puzzling. I made this script for Euler #50.
It calculates all the primes under 1M first, then looks through them for a solution. The first part (finding primes) is blazing fast under PyPy (as expected). But in the second part PyPy lags behind. CPython managed it in 183s, while PyPy did it in 498s. I'm assuming it has something to do with the list slicing?
I cannot reproduce, for me pypy is faster on both pieces of code:
viper ~ $ pypyc /tmp/euler.py ('All primes below', 1000000, 'found') 0.43 Max sequence is: .... .... ('It contains', 543, 'elements') ('The sum is', 997651) 72.61
viper ~ $ python /tmp/euler.py ('All primes below', 1000000, 'found') 4.58 Max sequence is: .... .... ('It contains', 543, 'elements') ('The sum is', 997651) 128.81
Could you tell us more about your environment, like which OS, cpu, 32/64 bit and the exact version of pypy/cpython you used to do the benchmark please?
ciao, Anto _______________________________________________ pypydev mailing list pypydev@python.org http://mail.python.org/mailman/listinfo/pypydev
participants (3)

Antonio Cuni

Maciej Fijalkowski

Mohyiddeen Othman