Re: New-style classes slower than old-style classes? (Was: n-body problem at shootout.alioth.debian.org)

2006-10-08 Thread Peter Maas
Peter Maas schrieb: > 1 runs of nbody.py, time in sec Correction: 1 iterations of advance(). -- Regards/Gruesse, Peter Maas, Aachen E-mail 'cGV0ZXIubWFhc0B1dGlsb2cuZGU=\n'.decode('base64') -- http://mail.python.org/mailman/listinfo/python-list

Re: New-style classes slower than old-style classes? (Was: n-body problem at shootout.alioth.debian.org)

2006-10-08 Thread Peter Maas
Richard Jones wrote: > Giovanni Bajo wrote: [...] >> Anyway, this is a bug on its own I believe. I don't think new-style >> classes are meant to be 25% slower than old-style classes. Can any guru >> clarify this? > > Please try 2.5 - there's been significant optimisation work put into 2.5 I check

Re: New-style classes slower than old-style classes? (Was: n-body problem at shootout.alioth.debian.org)

2006-10-07 Thread Richard Jones
Giovanni Bajo wrote: > Peter Maas wrote: > >>> Did you try using an old-style class instead of a new-style class? >> >> The original program has an old style class, changing it to a new >> style class increases run time by 25% (version is 2.4.3 btw). > > Ah yes. Years ago when I first saw this t

New-style classes slower than old-style classes? (Was: n-body problem at shootout.alioth.debian.org)

2006-10-07 Thread Giovanni Bajo
Peter Maas wrote: >> Did you try using an old-style class instead of a new-style class? > > The original program has an old style class, changing it to a new > style class increases run time by 25% (version is 2.4.3 btw). Ah yes. Years ago when I first saw this test it was still using new-style c

Re: n-body problem at shootout.alioth.debian.org

2006-10-07 Thread igouy
Peter Maas wrote: > Paul McGuire wrote: > > The advance method is the most fertile place for optimization, since it is > > called approximately n(n-1)/2 times (where n=2E7). I was able to trim about > > 25% from the Python runtime with these changes: > [...] > > My results: > > Your changes: 18%

Re: n-body problem at shootout.alioth.debian.org

2006-10-07 Thread Peter Maas
Paul McGuire wrote: > The advance method is the most fertile place for optimization, since it is > called approximately n(n-1)/2 times (where n=2E7). I was able to trim about > 25% from the Python runtime with these changes: [...] My results: Your changes: 18% runtime decrease Your changes + o

Re: n-body problem at shootout.alioth.debian.org

2006-10-07 Thread Peter Maas
Giovanni Bajo wrote: > Did you try using an old-style class instead of a new-style class? The original program has an old style class, changing it to a new style class increases run time by 25% (version is 2.4.3 btw). -- Regards/Gruesse, Peter Maas, Aachen E-mail 'cGV0ZXIubWFhc0B1dGlsb2cuZGU=\n

Re: n-body problem at shootout.alioth.debian.org

2006-10-07 Thread Peter Maas
[EMAIL PROTECTED] wrote: >> You might also put the outer loop calling function advance so many >> times, into the advance function: > > Remember that the autors of the Shootout refuse some changes to the > code (like this one), to allow a fair comparison. The rules are strict. I'm only aware of t

Re: n-body problem at shootout.alioth.debian.org

2006-10-07 Thread bearophileHUGS
Paddy: > You might also put the outer loop calling function advance so many > times, into the advance function: Remember that the autors of the Shootout refuse some changes to the code (like this one), to allow a fair comparison. The rules are strict. I have improved the Psyco version: http://sho

Re: n-body problem at shootout.alioth.debian.org

2006-10-07 Thread Giovanni Bajo
Peter Maas wrote: > I have noticed that in the language shootout at > shootout.alioth.debian.org the Python program for the n-body problem > is about 50% slower than the Perl program. This is an unusual big > difference. I tried to make the Python program faster but without > success. Has anybody

Re: n-body problem at shootout.alioth.debian.org

2006-10-06 Thread Paddy
[EMAIL PROTECTED] wrote: > [EMAIL PROTECTED] wrote: > > Ah, wait a moment. One more tweak. Make the body class a psyco class. > > That improves the runtime to 3.02s. Diff appended. > > Nice. Maybe you can do the same trick with: > from psyco.classes import __metaclass__ > > If you want you can

Re: n-body problem at shootout.alioth.debian.org

2006-10-06 Thread Peter Maas
Matteo wrote: > Of course, numpy is not a standard package (though there is a proposal > to add a standard 'array' package to python, based of numpy/numeric), > but if you want to do any numerics with python, you shouldn't be > without it. I know that nbody.py could be speeded up by psyco and nump

Re: n-body problem at shootout.alioth.debian.org

2006-10-06 Thread Peter Maas
John J. Lee wrote: > Replacing ** with multiplication in advance() cut it down to 0.78 > times the original running time for me. That brings it along side > PHP, one place below Perl (I didn't bother to upload the edited script). I tried this also but got only 90%. Strange. -- Regards/Gruesse,

Re: n-body problem at shootout.alioth.debian.org

2006-10-06 Thread bearophileHUGS
[EMAIL PROTECTED] wrote: > Ah, wait a moment. One more tweak. Make the body class a psyco class. > That improves the runtime to 3.02s. Diff appended. Nice. Maybe you can do the same trick with: from psyco.classes import __metaclass__ If you want you can try that trick with this version of mine

Re: n-body problem at shootout.alioth.debian.org

2006-10-06 Thread Paul McGuire
"Peter Maas" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] >I have noticed that in the language shootout at shootout.alioth.debian.org > the Python program for the n-body problem is about 50% slower than the > Perl > program. This is an unusual big difference. I tried to make the Py

Re: n-body problem at shootout.alioth.debian.org

2006-10-06 Thread skip
Skip> I took the original version, tweaked it slightly (probably did Skip> about the same things as Python #2, I didn't look). For N == Skip> 200,000 the time went from 21.94s (user+sys) to 17.22s. Using Skip> psyco and binding just the advance function on my improved version

Re: n-body problem at shootout.alioth.debian.org

2006-10-06 Thread Matteo
Peter Maas wrote: > I have noticed that in the language shootout at shootout.alioth.debian.org > the Python program for the n-body problem is about 50% slower than the Perl > program. This is an unusual big difference. I tried to make the Python program > faster but without success. Has anybody an

Re: n-body problem at shootout.alioth.debian.org

2006-10-06 Thread Neil Cerutti
On 2006-10-06, Peter Maas <[EMAIL PROTECTED]> wrote: > I have noticed that in the language shootout at > shootout.alioth.debian.org the Python program for the n-body > problem is about 50% slower than the Perl program. This is an > unusual big difference. I tried to make the Python program > faster

Re: n-body problem at shootout.alioth.debian.org

2006-10-06 Thread skip
Peter> I have noticed that in the language shootout at Peter> shootout.alioth.debian.org the Python program for the n-body Peter> problem is about 50% slower than the Perl program. This is an Peter> unusual big difference. I tried to make the Python program faster Peter> but wi

Re: n-body problem at shootout.alioth.debian.org

2006-10-06 Thread bearophileHUGS
Peter Maas: > I have noticed that in the language shootout at shootout.alioth.debian.org > the Python program for the n-body problem is about 50% slower than the Perl > program. This is an unusual big difference. I tried to make the Python program > faster but without success. Has anybody an explan

Re: n-body problem at shootout.alioth.debian.org

2006-10-06 Thread John J. Lee
Peter Maas <[EMAIL PROTECTED]> writes: > I have noticed that in the language shootout at shootout.alioth.debian.org > the Python program for the n-body problem is about 50% slower than the Perl > program. This is an unusual big difference. I tried to make the Python program > faster but without su

n-body problem at shootout.alioth.debian.org

2006-10-06 Thread Peter Maas
I have noticed that in the language shootout at shootout.alioth.debian.org the Python program for the n-body problem is about 50% slower than the Perl program. This is an unusual big difference. I tried to make the Python program faster but without success. Has anybody an explanation for the differ