Paul Rubin wrote: > Steven D'Aprano <[EMAIL PROTECTED]> writes: >> or even >> >> len(filter(lambda t, y=y: y>t, x)) > > > How about > > min(i for i,t in enumerate(x) if t >= y) > > or > > max(i for i,t in enumerate(x) if t <= y) > > Those are actually pretty direct.
How about a solution (like the bisect one suggested almost as soon as this thread started) that doesn't iterate over the whole list. Having said which, for the promoted use cases I agree that the append() and sort() paradigm wins hands down until it starts to make a real and observable difference to the run time. regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://del.icio.us/steve.holden Recent Ramblings http://holdenweb.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list