PyRoaring

1.0.4 · active · verified Sun Mar 29

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.

Warnings

Install

Imports

Quickstart

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}")

view raw JSON →