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

Peter Maas peter.maas at somewhere.com
Sat Oct 7 17:32:28 EDT 2006


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 + objects->lists: 25% runtime decrease

The Python program is much closer to the Perl program then (~2250 vs 1900 sec)
but replacing the objects by lists is not worth the effort because the gain is
small and the Python program becomes less readable.

Taking arrays (from module array) instead of lists increases runtime by 19%!

If it weren't for the shootout I would of course take psyco and numpy.

-- 
Regards/Gruesse,

Peter Maas, Aachen
E-mail 'cGV0ZXIubWFhc0B1dGlsb2cuZGU=\n'.decode('base64')



More information about the Python-list mailing list