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

attn.steven.kuo at gmail.com attn.steven.kuo at gmail.com
Thu Jan 31 18:24:15 EST 2008


On Jan 31, 3:09 pm, Paul Rubin <http://phr...@NOSPAM.invalid> wrote:
> "attn.steven.... at gmail.com" <attn.steven.... at gmail.com> writes:
> > mysets = [set(range(x[2],x[1])) for x in mylist]
>
> This is pretty horrible, each set can be arbitrarily large,
> i.e. if x[2] and x[1] are 0 and 1000000, you get a set with
> a million elements.



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.

xset?

--
Regards,
Steven



More information about the Python-list mailing list