Registry / database / pyroaring

pyroaring

JSON →
library1.1.0pypypi✓ verified 27d ago

PyRoaring is a Python library providing an efficient and light-weight ordered set of integers. It serves as a Python wrapper for the highly optimized C library CRoaring, which implements Roaring Bitmaps. The library is actively maintained, with the current version being 1.0.4, and sees regular releases with new features and improvements.

pip install pyroaring
INSTALL
IMPORT
SIG · PYROARING
P
pyroaring
databasepythonv1.1.0
Install
1.8s avg
Import
10ms
Disk
24MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.1.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.002s · 26.7MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.8s · import 0.000s · 26MB
24MB installed
● package 24MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

BitMap
from pyroaring import BitMap
BitMap64
from pyroaring import BitMap64
Use BitMap64 for integers larger than 2**32-1.

This example demonstrates creating two Roaring BitMaps, adding elements, initializing from a list, performing intersection and union operations, and checking for element existence.

from pyroaring import BitMap bm1 = BitMap() bm1.add(3) bm1.add(18) bm2 = BitMap([3, 27, 42]) print(f"bm1 = {bm1}") print(f"bm2 = {bm2}") print(f"bm1 & bm2 = {bm1 & bm2}") print(f"bm1 | bm2 = {bm1 | bm2}") print(f"Does bm1 contain 3? {3 in bm1}")
Debug
Known issues
breakingPython 3.7 support was dropped in PyRoaring 1.0.0, and Python 3.8 support was dropped in PyRoaring 1.0.4. Users on these older Python versions must use an earlier PyRoaring release.
fix
Upgrade to Python 3.9 or higher, or pin pyroaring to an earlier version (e.g., `<1.0.0` for Python 3.7, `<1.0.4` for Python 3.8).
affects: 1.0.0 and later (for Python 3.7), 1.0.4 and later (for Python 3.8)
breakingPrior to version 1.0.0, in-place operations where a BitMap was modified by itself (e.g., `bm &= bm`) were not correctly handled due to an underlying CRoaring library limitation. This was fixed in 1.0.0.
fix
Upgrade to PyRoaring 1.0.0 or later to ensure correct behavior for in-place self-operations. If upgrading is not possible, avoid such operations or create a copy before modifying.
affects: <1.0.0
gotchaWhen compiling PyRoaring from source, specific Cython version compatibility issues have been noted. Version 1.0.2 restricted Cython to `<3.1.0` due to a bug, although earlier 0.4.3 added general Cython 3 compatibility. Ensure your Cython version is compatible with the PyRoaring version you are compiling.
fix
If compiling from source, consult the PyRoaring release notes or `setup.py` for recommended Cython versions. For most users, installing pre-built wheels with `pip install pyroaring` avoids this issue.
affects: All versions, especially around Cython 3.0/3.1
gotchaSafe deserialization of bitmaps was introduced in PyRoaring 1.0.1. Earlier versions might be vulnerable to issues if deserializing untrusted or malformed data.
fix
Upgrade to PyRoaring 1.0.1 or later to benefit from safe deserialization, especially when handling data from external sources.
affects: <1.0.1
gotchaPyRoaring offers two main classes: `BitMap` for 32-bit integers (0 to 2**32-1) and `BitMap64` for 64-bit integers (0 to 2**64-1). Using `BitMap` for values exceeding 2**32-1 will lead to incorrect behavior or errors.
fix
Always use `from pyroaring import BitMap64` when working with integers that may exceed the 32-bit unsigned integer range.
affects: All versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'pyroaring'
The 'pyroaring' package is not installed in the Python environment, or the environment where it's installed is not the one being used.
fix
Install the package using pip: `pip install pyroaring`
AttributeError: module 'pyroaring' has no attribute 'BitMap'
The 'BitMap' alias for 'RoaringBitmap' was deprecated in pyroaring version 0.5.0 and fully removed in version 0.6.0. Older code or tutorials might still reference it.
fix
Use 'RoaringBitmap' instead of 'BitMap'. For example: `from pyroaring import RoaringBitmap`
TypeError: expected an integer
Methods like 'add()', 'discard()', or 'update()' in pyroaring are designed to work exclusively with integer values, but a non-integer (e.g., float or string) was provided.
fix
Ensure that only integer values are passed to pyroaring methods that expect integer elements.
Failed building wheel for pyroaring
As a C extension, pyroaring requires a C compiler (like GCC or Clang) and Python development headers to build from source if a pre-built wheel is not available for your specific Python version and operating system.
fix
Install the necessary build tools for your operating system (e.g., `sudo apt-get install build-essential python3-dev` on Debian/Ubuntu, `xcode-select --install` on macOS, or Visual C++ Build Tools on Windows).
Upgrade
Version history
1.1.0latest on PyPI · released Apr 24, 2026
Audit
Dependencies

No dependency data recorded yet.

Agent activity
20 hits · last 30 days
node
18
Resources
pyroaring — pip install pyroaring · libregistry