Index of maximum element in list

Arnaud Delobelle arnodel at googlemail.com
Sun Jan 27 14:02:38 CET 2008


On Jan 27, 11:32 am, Arnaud Delobelle <arno... at googlemail.com> wrote:

[...]
>
> simple_posmax is more than 3x faster on my machine.  It's not
> surprising as even though the list is walked twice, it is all done in
> C and no new objects have to be created. Then only non-C bit is when
> the result of max(l) is fed to l.index().

Of course that's incorrect in general: if comparison functions between
objects in l are python functions then some bytecode will be run and
some new objects may be created.  But in most cases I think it stands
true.

--
Arnaud




More information about the Python-list mailing list