On Mar 17, 9:46 pm, Steve Holden <[EMAIL PROTECTED]> wrote:
> 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.
>

Unfortunately for sort/append, the OP wants to find the insertion
point -- he hasn't mentioned actually doing the insertion.


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

Reply via email to