Index of maximum element in list

Paul Rubin http
Sat Jan 26 17:18:04 EST 2008


Steven D'Aprano <steve at REMOVE-THIS-cybersource.com.au> writes:
> Actually there is a big speed hit. Until such time that Python has a fast 
> identity function, and lambda x:x isn't it, your version is about three 
> times slower than Bearophile's.

Interesting.  Fixing that speed hit probably needs compiler attention.

> Much to my surprise, the fastest solution I've tried appears to be a pure 
> Python version not even using max() at all.

Could you try the l.index version?  That avoids creating all those
intermediate tuples.



More information about the Python-list mailing list