[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 try that trick with this version of mine: > http://shootout.alioth.debian.org/sandbox/benchmark.php?test=nbody&lang=psyco&id=3 > > (I can't try it, precompiled Psyco doesn't exists yet for Py2.5). If > it's faster, then I can upload some modified version... > > Bye, > bearophile
You might also put the outer loop calling function advance so many times, into the advance function: ========== def advance(bodies, dt, n) : for i in xrange(n) : for i,b in enumerate(bodies) : ... def main() : ... advance(bodies, 0.01, n) ========== This I like. It points to areas of python where maybe we should be adding to the standard library whilst also showing off the cream of the non-standard libraries out their. - Paddy. -- http://mail.python.org/mailman/listinfo/python-list