IntSet
IntSets are an efficient immutable representation of sets of unsigned 64-bit integers with fast boolean operations and fast indexing of the set in sorted order. They are designed to be particularly efficient for representing sets with large contiguous ranges, so for example representing the set of all 64-bit integers takes only a handful of bytes.
Their behaviour and API are somewhere in between that of frozenset and that of a sorted list of deduplicated integers.
The implementation is heavily based on Fast Mergeable Integer Maps by Okasaki and Gill, but it has been adapted to support a somewhat different feature set and a more compact representation for certain usage patterns.
Installation
pip install intset
intset supports Python 3.10 and later, and has no dependencies.
Usage
>>> from intset import IntSet
>>> x = IntSet([1, 2, 3, (16, 32)])
>>> x
IntSet([(1, 4), (16, 32)])
>>> 20 in x
True
>>> len(x)
19
>>> x[-1]
31
>>> x | IntSet.interval(4, 16)
IntSet([(1, 32)])
>>> (~x).size() == 2 ** 64 - 19
True
For more, see the API documentation.
Development
Development uses uv and just. Run just to list the available recipes, and just check to run everything that continuous integration runs.
Metadata
Release files for intset 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| intset-1.1.0.tar.gz | 15.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| intset-1.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 24.4 kB
Release files / intset-1.1.0.tar.gz
| Download URL | intset-1.1.0.tar.gz |
|---|---|
| Size | 15.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f609e45f95a6ab171f880098bed5fc23e6a3e91154c0669d3d2371712a389c20
|
|
BLAKE2b-256 checksum How to use checksums |
a6749e1bfcb12243e48e35420f04549354bb6df1c85a5fd0ac3896684f05c9a4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 24, 2026.
Transparency logRelease files / intset-1.1.0-py3-none-any.whl
| Download URL | intset-1.1.0-py3-none-any.whl |
|---|---|
| Size | 9.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ea6d6e4f7ecccf72f20ef8c6fd76dd9661465a0c5ae8a7b9f6e0332e3dba91e1
|
|
BLAKE2b-256 checksum How to use checksums |
8d8d26bbf5dbedac1a0d04ce1a9efd5539fd76636fcca79dd0aa525a01515a22
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 24, 2026.
Transparency log