How to identify which numbers in a list are within each others' range

George Sakkis george.sakkis at gmail.com
Thu Jan 31 20:34:45 EST 2008


On Jan 31, 7:11 pm, Paul Rubin <http://phr...@NOSPAM.invalid> wrote:
> "attn.steven.... at gmail.com" <attn.steven.... at gmail.com> writes:
> > True...  Any lighter-weight implementation of
> > sets out there?  That is, one that would defer
> > use of resources until actually needed --
> > somewhat akin to the distinction between
> > range and xrange, and so on.
>
> Don't even think of doing it that way, that solves the space problem
> but leaves a speed problem.  You probably want to use something like
> sort the intervals and then use the bisect module to find the
> intervals intersecting a given one.

I haven't actually used it but from the short description this package
seems to fit the bill: http://pypi.python.org/pypi/interval/1.0.0

George



More information about the Python-list mailing list