Number set type

Heiko Wundram modelnine at bit-bukket.org
Wed Dec 28 20:32:22 EST 2005


Hi all!

I'm wondering whether there is some form of number set type implemented in
pure Python. I'm currently in the process of implementing one myself (for
an IPv4 address range type), and if there's some form of reference
implementation I'd love to see it. I've not found a reasonably complete
implementation anywhere so far.

To explain what I mean with number set: a set type that doesn't store
individual entries but as it only contains numbers can store ranges of
numbers.

Basically what it boils down to is implementing intersection reasonably
fast, because all other set operations can be reduced to intersection and
union (which is easy to implement). I have implementations for both, but
only union is fast with O(n), intersection is currently O(n^2).

But, anyway, if anybody knows of some implementation I can have a look at,
please let me know.

Thanks!

--- Heiko.



More information about the Python-list mailing list