Skip to main content

Implementation of integer relations based on roaring bitmaps.

Project description

RoaringRel

Python versions PyPI version PyPI status Checked with Mypy Documentation Status

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 the Rel class along with the Shape and Entry type aliases.
  • test/ — the test suite, run with pytest.
  • 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

LGPLv3 © Hashberg.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

roaringrel-1.1.0.tar.gz (23.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

roaringrel-1.1.0-py3-none-any.whl (22.5 kB view details)

Uploaded Python 3

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

Hashes for roaringrel-1.1.0.tar.gz
Algorithm Hash digest
SHA256 7d57254205ed0b2d807a83803dc5fdddb5721d71877442e59603a2cabd53615c
MD5 a53910f7e954a9f3d0748fd61059cecb
BLAKE2b-256 ebf08cbd48b4033197a89c1cbb8b6937542db43aa5a891f3f00e7dd6f28d0add

See more details on using hashes here.

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

Hashes for roaringrel-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 db2fd2d3a1bea6987560c7f1587a956c351f8101c3bde5039588fee887a4086b
MD5 8c03a3e86538882f259cca25d3d24baf
BLAKE2b-256 c0c7e31f209c2cbc452568729ee05e745bf43f63b875ffa1e5a07f70e6dfe0b4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page