On Jan 21, 8:48 am, Peter Otten <[EMAIL PROTECTED]> wrote:

> Neal Becker wrote:
> > What's a good/fast way to find the index of the minimum element of a
> > sequence?
...

> >>> min(xrange(len(items)), key=items.__getitem__)
...

Or just
   items.index(min(items))
I found this to be significantly faster in a simple test (searching a
list of 1000 ints with the minimum in the middle), despite the fact
that it requires two passes.  I'm sure that one could find cased where
Peter's approach is faster, so you if you are concerned about speed
you should measure with your own data.



-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to