Index of maximum element in list

bearophileHUGS at lycos.com bearophileHUGS at lycos.com
Sun Jan 27 05:49:25 EST 2008


bearophile:
> That version is easy to translate to other languages and you can
> probably find that Psyco makes it much faster still.

That operation is quite common, so it deserves a bit more work:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/543271

(I can show you the D/C code if you want it. The C code is just for
testing, while the D code is usable).

The final sum: the Psyco version is almost 40 times faster than the
Python version, and just 2.8 times slower than the D version, and 3.4
times slower than a C version (that doesn't use too many pointer
tricks). I think this is good enough.

Bye,
bearophile



More information about the Python-list mailing list