Find an Item in a Sorted List

Jason Orendorff jason at jorendorff.com
Tue Feb 26 19:47:23 EST 2002


> More general...  does filter() have any performance advantage over
> just using a for loop?  The datafile list has 10,000+ items.  My
> background is in object pascal where I would read the items into a
> list then use a binary search to find the target.  I'm hoping there's
> an efficient python method to perform a search easily on a sorted
> list.

import bisect

Also note the startswith() method of strings.

## Jason Orendorff    http://www.jorendorff.com/








More information about the Python-list mailing list