searching a list of tuples

Emile van Sebille emile at fenx.com
Wed Feb 13 12:25:31 EST 2002


"Marcus Stojek" <stojek at part-gmbh.de> wrote in message
news:3c6aabeb.6302984 at news.easynews.net...
> Hi,
>
> I have a (huge) list of tuples :
> list=(float 1,float 2,float 3,int).
>
> The list has been sorted with list.sort()
> Now I have to slice the list in a way
> that:
>
>   a <= float 1 <= b
>
> As I have to do this very often for different
> values of a and b and the list is quite large
> (100.000 tuples) I would like to do the slicing
> as fast as possible.
>
> Can anybody help me?
>

>>> import bisect
>>> bisect.bisect(range(1,1000,3),500)
167
>>>


--

Emile van Sebille
emile at fenx.com

---------




More information about the Python-list mailing list