[Tutor] Searching Sorted Lists

2005-08-19 Thread DaSmith
Hi, Can someone tell me if there is a bulit in Binary search function for python lists ? I am currently building lists and sorting them with a comparison function. The only list search function I know is List.Index(X), which is pretty inefficient I reckon, especially hen the lists are likely t

Re: [Tutor] Searching Sorted Lists

2005-08-19 Thread Danny Yoo
> Hi, Can someone tell me if there is a bulit in Binary search function > for python lists ? > > I am currently building lists and sorting them with a comparison > function. The only list search function I know is List.Index(X), which > is pretty inefficient I reckon, especially hen the lists are

Re: [Tutor] Searching Sorted Lists

2005-08-19 Thread Kent Johnson
[EMAIL PROTECTED] wrote: > > Hi, Can someone tell me if there is a bulit in Binary search function for > python lists ? The bisect module implements a binary search though it doesn't support custom comparison functions. You could make your list elements be instances of a class with a __cmp__()

Re: [Tutor] Searching Sorted Lists

2005-08-20 Thread Alan G
> The only list search function I know is List.Index(X), which is > pretty > inefficient I reckon, especially hen the lists are likely to contain > 100's > or 100's of members. Have you tried it? How long is it taking? I'd be very surprised if it there was a serious problem indexing a list of ev

Re: [Tutor] Searching Sorted Lists

2005-08-20 Thread Andrei
[EMAIL PROTECTED] wrote: > Hi, Can someone tell me if there is a bulit in Binary search function for > python lists ? > > I am currently building lists and sorting them with a comparison function. > The only list search function I know is List.Index(X), which is pretty > inefficient I reckon, espe

Re: [Tutor] Searching Sorted Lists

2005-08-21 Thread R. Alan Monroe
> [EMAIL PROTECTED] wrote: >> Hi, Can someone tell me if there is a bulit in Binary search function for >> python lists ? >> >> I am currently building lists and sorting them with a comparison function. >> The only list search function I know is List.Index(X), which is pretty >> inefficient I reck