Install pyroaring from conda-forge
masterConda users can install the package from the conda-forge channel. This supports Python 3.6 or higher on Mac, Linux, and Windows.
conda install -c conda-forge pyroaringrepository·master·Indexed 42 days ago
https://github.com/ezibenroc/pyroaringbitmapA high-performance Python wrapper for the CRoaring C library that provides efficient, ordered sets of 32-bit and 64-bit integers using Roaring Bitmaps. It features BitMap and BitMap64 classes supporting membership testing, addition, and set operations such as intersection, union, and difference.
Conda users can install the package from the conda-forge channel. This supports Python 3.6 or higher on Mac, Linux, and Windows.
conda install -c conda-forge pyroaringTo build and test from source using uv:
uv build3. Run tests:
```bash
uv run --with=pytest --with=hypothesis --with="$(ls dist/pyroaring-*.whl)" pytest test.pyNote: Windows users require a different way to specify the wheel in the test command.
If you use uv for dependency management, add pyroaring to your project using:
uv add pyroaringInstall pyroaring from PyPI using pip.
Supported Systems: Linux, MacOS, or Windows. Requirements: Python 3.9 or higher (older versions may work but are not tested).
It is recommended to use a virtual environment:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install pyroaringpip install pyroaringTo compile and install from source (useful for modifying Cython sources), you need an appropriate C compiler.
git clone https://github.com/Ezibenroc/PyRoaringBitMap.git
cd PyRoaringBitMappython -m pip install .This will automatically install Cython if missing, cythonize source files, and compile the package.Quick Recompilation for Testing: To recompile the package in place without a full reinstall:
python setup.py build_clib
python setup.py build_ext -iNote: build_clib compiles croaring only and only needs to be run once.
git clone https://github.com/Ezibenroc/PyRoaringBitMap.git
python -m pip install .On recent Intel and AMD (x64) processors under Linux, you can achieve better performance by building CRoaring specifically for your machine's architecture.
Warning: The resulting binary may only run on your specific machine.
ARCHI=native pip install pyroaring --no-binary :all:Note: This approach may not work under macOS.
ARCHI=native pip install pyroaring --no-binary :all:The pyroaring library provides an efficient, lightweight ordered set of integers by wrapping the CRoaring C library. You can use it similarly to a standard Python set.
BitMap for 32-bit integers (values from 0 to $2^{32}-1$).BitMap64 for 64-bit integers (values from 0 to $2^{64}-1$).Supported operations include membership testing (in), addition (add), and set operations like intersection (&), union (|), and difference.
from pyroaring import BitMap
# Initialize and add elements
bm1 = BitMap()
bm1.add(3)
bm1.add(18)
# Membership testing
print("has 3:", 3 in bm1)
print("has 4:", 4 in bm1)
# Initialize from list
bm2 = BitMap([3, 27, 42])
# Set operations
print("bm1 = %s" % bm1)
print("bm2 = %s" % bm2)
print("bm1 & bm2 = %s" % (bm1&bm2))
print("bm1 | bm2 = %s" % (bm1|bm2))When building from source, you can use environment variables to control compilation:
DEBUG=1: Build in debug mode.ARCHI=<cpu-type>: Build for a specific platform using keywords compatible with the -march option of gcc.Example:
DEBUG=1 ARCHI=x86-64 python setup.py build_ext