Skip to content

scravy/frozenintset

Repository files navigation

frozenintset

FrozenIntSet is an immutable, memory-efficient set of integers. It fully conforms to collections.abc.Set[int] and stores values as a sorted list of non-overlapping ranges.

from frozenintset import FrozenIntSet

s = FrozenIntSet({-5, -4, -3, -2, 4, 9, 10, 20, 21, 22})

Why frozenintset?

✅ Immutable and hashable (usable as dict keys or cache keys)

✅ Efficient for both dense and sparse integer sets

✅ Fast membership testing, iteration, slicing, and set operations

✅ Supports arbitrary-size integers (no 64-bit limit)

Alternatives

intset
A highly optimized, trie-backed implementation.
⚠️ Limited to 64-bit unsigned integers only.
rangeset
Supports open and unbounded ranges and arbitrary types. More general, but frozenintset is faster for plain integers.

About

An immutable, memory-efficient set of integers implementation for Python.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published