Implementation of integer relations based on roaring bitmaps.
Project description
RoaringRel
RoaringRel is a low-level mutable data structure for finite relations R ⊆ X₁ × ... × Xₙ between finite sets, built on 64-bit roaring bitmaps.
It presumes that the component sets X₁,...,Xₙ are zero-based contiguous integer ranges Xⱼ = {0,...,sⱼ-1}: the tuple (s₁,...,sₙ) of component set sizes is the shape of the relation, and the tuples (x₁,...,xₙ) ∈ R are its entries.
Install
You can install the latest release from PyPI as follows:
$ pip install roaringrel
Usage
All functionality of the library is accessible from the Rel class, which is created from a shape and, optionally, some initial entries:
>>> from roaringrel import Rel
>>> r = Rel((2, 3, 4), [(0, 0, 0), (1, 1, 1), (1, 2, 3)])
>>> len(r)
3
>>> (0, 0, 0) in r
True
Relations behave as sets of entries, supporting the usual binary operators (&, |, ^, -), their in-place counterparts, containment comparison, and entry-wise mutation via add, remove and flip.
Because this is a low-level structure aimed at performance-critical code, entries are normalised rather than validated: out-of-range elements wrap around modulo their component set size, and no method rejects an entry.
This cannot corrupt a relation — every entry normalises into a valid slot — but it does mean that an out-of-range entry silently addresses a different one.
Use the validate_entry method where that tradeoff is not acceptable; it is never called internally, so validation costs nothing unless you ask for it.
For an overview of library features and usage, see the getting started guide.
Project structure
roaringrel/— the library itself, a single module defining theRelclass along with theShapeandEntrytype aliases.test/— the test suite, run withpytest.docs/— the Sphinx documentation sources, together with the scripts used to generate the API documentation.autodoc_typehints.py— a custom Sphinx extension which renders type hints in the API documentation.
API
For the full API documentation, see https://roaringrel.readthedocs.io/.
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file roaringrel-1.1.0.tar.gz.
File metadata
- Download URL: roaringrel-1.1.0.tar.gz
- Upload date:
- Size: 23.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7d57254205ed0b2d807a83803dc5fdddb5721d71877442e59603a2cabd53615c
|
|
| MD5 |
a53910f7e954a9f3d0748fd61059cecb
|
|
| BLAKE2b-256 |
ebf08cbd48b4033197a89c1cbb8b6937542db43aa5a891f3f00e7dd6f28d0add
|
File details
Details for the file roaringrel-1.1.0-py3-none-any.whl.
File metadata
- Download URL: roaringrel-1.1.0-py3-none-any.whl
- Upload date:
- Size: 22.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
db2fd2d3a1bea6987560c7f1587a956c351f8101c3bde5039588fee887a4086b
|
|
| MD5 |
8c03a3e86538882f259cca25d3d24baf
|
|
| BLAKE2b-256 |
c0c7e31f209c2cbc452568729ee05e745bf43f63b875ffa1e5a07f70e6dfe0b4
|