Skip to main content

Fast and lightweight set for unsigned 32 bits integers.

Project description

Documentation Status

An efficient and light-weight ordered set of 32 bits integers. This is a Python wrapper for the C library CRoaring.

Example

You can use a bitmap nearly as the classical Python set in your code:

from pyroaring import BitMap
bm1 = BitMap()
bm1.add(3)
bm1.add(18)
bm2 = BitMap([3, 27, 42])
print("bm1       = %s" % bm1)
print("bm2       = %s" % bm2)
print("bm1 & bm2 = %s" % (bm1&bm2))
print("bm1 | bm2 = %s" % (bm1|bm2))

Output:

bm1       = BitMap([3, 18])
bm2       = BitMap([3, 27, 42])
bm1 & bm2 = BitMap([3])
bm1 | bm2 = BitMap([3, 18, 27, 42])

Installation from Pypi

Supported systems: Linux, MacOS or Windows, Python 3.5 or higher. Note that pyroaring might still work with older Python versions, but they are not tested anymore.

To install pyroaring on your local account, use the following command:

pip install pyroaring --user

For a system-wide installation, use the following command:

pip install pyroaring

Naturally, the latter may require superuser rights (consider prefixing the commands by sudo).

If you want to use Python 3 and your system defaults on Python 2.7, you may need to adjust the above commands, e.g., replace pip by pip3.

Installation from conda-forge

Conda users can install the package from conda-forge:

conda install -c conda-forge pyroaring

(Supports Python 3.6 or higher; Mac/Linux/Windows)

Manual compilation / installation

If you want to compile (and install) pyroaring by yourself, for instance to modify the Cython sources or because you do not have pip, follow these steps.

Note that the Python package Cython is required. You may install it as:

pip install --upgrade setuptools -user
pip install cython --user

Clone this repository.

git clone https://github.com/Ezibenroc/PyRoaringBitMap.git
cd PyRoaringBitMap
git submodule init && git submodule update

Build pyroaring locally, e.g. to test a new feature you made.

python setup.py build_ext -i

On macOS this may fail with errors because setuptools adds -arch x86_64 -arch i386 to the compiler command, which may conflict with the -march=native flag. You can overwrite this behavior by setting the ARCHFLAGS flag:

ARCHFLAGS="" python setup.py build_ext -i

Then you can test the new code:

pip install hypothesis --user
python test.py # run the tests, optional but recommended

Install pyroaring (use this if you do not have pip).

python setup.py install # may require superuser rights, add option --user if you wish to install it on your local account

Package pyroaring.

python setup.py sdist
pip install dist/pyroaring-0.1.?.tar.gz # optionnal, to install the package

Build a wheel.

python setup.py bdist_wheel

For all the above commands, two environment variables can be used to control the compilation.

  • DEBUG=1 to build pyroaring in debug mode.

  • ARCHI=<cpu-type> to build pyroaring for the given platform. The platform may be any keyword given to the -march option of gcc (see the documentation). Note that cross-compiling for a 32-bit architecture from a 64-bit architecture is not supported.

Example of use:

DEBUG=1 ARCHI=x86-64 python setup.py build_ext

Optimizing the builds for your machine (x64)

For recent Intel and AMD (x64) processors under Linux, you may get better performance by requesting that CRoaring be built for your machine, specifically, when building from source. Be mindful that when doing so, the generated binary may only run on your machine.

ARCHI=native pip install pyroaring  --no-binary :all:

This approach may not work under macOS.

Benchmark

Pyroaring is compared with the built-in set and other implementations:

The script quick_bench.py measures the time of different set operations. It uses randomly generated sets of size 1e6 and density 0.125. For each operation, the average time (in seconds) of 30 tests is reported.

The results have been obtained with:

  • CPU Intel Xeon CPU E5-2630 v3

  • CPython version 3.5.3

  • gcc version 6.3.0

  • Cython version 0.28.3

  • pyroaring commit dcf448a

  • python-croaring commit 3aa61dd

  • roaringbitmap commit 502d78d

  • sortedcontainers commit 7d6a28c

operation

pyroaring

python-croaring

roaringbitmap

set

sortedcontainers

range constructor

3.09e-04

1.48e-04

8.72e-05

7.29e-02

2.08e-01

ordered list constructor

3.45e-02

6.93e-02

1.45e-01

1.86e-01

5.74e-01

list constructor

1.23e-01

1.33e-01

1.55e-01

1.12e-01

5.12e-01

ordered array constructor

5.06e-03

6.42e-03

2.89e-01

9.82e-02

3.01e-01

array constructor

1.13e-01

1.18e-01

4.63e-01

1.45e-01

5.08e-01

element addition

3.08e-07

8.26e-07

2.21e-07

1.50e-07

1.18e-06

element removal

3.44e-07

8.17e-07

2.61e-07

1.78e-07

4.26e-07

membership test

1.24e-07

1.00e-06

1.50e-07

1.00e-07

5.72e-07

union

1.61e-04

1.96e-04

1.44e-04

2.15e-01

1.11e+00

intersection

9.08e-04

9.48e-04

9.26e-04

5.22e-02

1.65e-01

difference

1.57e-04

1.97e-04

1.43e-04

1.56e-01

4.84e-01

symmetric diference

1.62e-04

2.01e-04

1.44e-04

2.62e-01

9.13e-01

equality test

7.80e-05

7.82e-05

5.89e-05

1.81e-02

1.81e-02

subset test

7.92e-05

8.12e-05

8.22e-05

1.81e-02

1.81e-02

conversion to list

4.71e-02

2.78e-01

4.35e-02

5.77e-02

5.32e-02

pickle dump & load

4.02e-04

6.27e-04

5.08e-04

2.41e-01

5.75e-01

“naive” conversion to array

5.12e-02

2.92e-01

4.75e-02

1.20e-01

1.18e-01

“optimized” conversion to array

1.27e-03

3.40e-02

nan

nan

nan

selection

1.77e-06

5.33e-05

1.14e-06

nan

1.64e-05

contiguous slice

9.38e-05

9.51e-05

6.99e-05

nan

2.04e-02

slice

2.88e-03

3.04e-01

1.00e-01

nan

4.74e-01

small slice

8.93e-05

3.00e-01

3.60e-03

nan

1.79e-02

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

pyroaring-0.3.1.tar.gz (318.1 kB view details)

Uploaded Source

Built Distributions

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

pyroaring-0.3.1-cp39-cp39-win_amd64.whl (209.8 kB view details)

Uploaded CPython 3.9Windows x86-64

pyroaring-0.3.1-cp39-cp39-macosx_10_14_x86_64.whl (279.8 kB view details)

Uploaded CPython 3.9macOS 10.14+ x86-64

pyroaring-0.3.1-cp38-cp38-win_amd64.whl (210.6 kB view details)

Uploaded CPython 3.8Windows x86-64

pyroaring-0.3.1-cp38-cp38-macosx_10_14_x86_64.whl (278.3 kB view details)

Uploaded CPython 3.8macOS 10.14+ x86-64

pyroaring-0.3.1-cp37-cp37m-win_amd64.whl (205.9 kB view details)

Uploaded CPython 3.7mWindows x86-64

pyroaring-0.3.1-cp37-cp37m-macosx_10_14_x86_64.whl (277.7 kB view details)

Uploaded CPython 3.7mmacOS 10.14+ x86-64

pyroaring-0.3.1-cp36-cp36m-win_amd64.whl (205.7 kB view details)

Uploaded CPython 3.6mWindows x86-64

pyroaring-0.3.1-cp36-cp36m-macosx_10_14_x86_64.whl (277.3 kB view details)

Uploaded CPython 3.6mmacOS 10.14+ x86-64

pyroaring-0.3.1-cp35-cp35m-win_amd64.whl (204.5 kB view details)

Uploaded CPython 3.5mWindows x86-64

pyroaring-0.3.1-cp35-cp35m-macosx_10_14_x86_64.whl (279.6 kB view details)

Uploaded CPython 3.5mmacOS 10.14+ x86-64

File details

Details for the file pyroaring-0.3.1.tar.gz.

File metadata

  • Download URL: pyroaring-0.3.1.tar.gz
  • Upload date:
  • Size: 318.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.7.10

File hashes

Hashes for pyroaring-0.3.1.tar.gz
Algorithm Hash digest
SHA256 1335a85230979332a00fbb3be658f97ff194b391d79d293e899225a9d73893ef
MD5 5f7f93759479714d2fff89520a0ba26f
BLAKE2b-256 68b680d91ca512e538d2fd2b404ab55c13a2cae63d1d8b5cbb59f5200d203a16

See more details on using hashes here.

File details

Details for the file pyroaring-0.3.1-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: pyroaring-0.3.1-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 209.8 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.5

File hashes

Hashes for pyroaring-0.3.1-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 18c2bde0cbad89f9d4abd7bee99cc465d6716ce0621c2a2ab4e32027f996b34a
MD5 29861fe9d5b4df1bdf281026537e7b4e
BLAKE2b-256 fe805150f202c9cce47c2ce858f26cae0b70aefaf0e8c1c93713650feec886c1

See more details on using hashes here.

File details

Details for the file pyroaring-0.3.1-cp39-cp39-macosx_10_14_x86_64.whl.

File metadata

  • Download URL: pyroaring-0.3.1-cp39-cp39-macosx_10_14_x86_64.whl
  • Upload date:
  • Size: 279.8 kB
  • Tags: CPython 3.9, macOS 10.14+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.5

File hashes

Hashes for pyroaring-0.3.1-cp39-cp39-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 ebfb8fa3111b59a26f00d22660ed7414ae92523e26e3e2fce1ff338ae39a9179
MD5 81dd2c57b35c156d90aa073349019c3b
BLAKE2b-256 8c0c2f1a45464cb68a48e5fa48c3419cbe50f39940475a3c690987d9181d600a

See more details on using hashes here.

File details

Details for the file pyroaring-0.3.1-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: pyroaring-0.3.1-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 210.6 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.8.10

File hashes

Hashes for pyroaring-0.3.1-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 d4632e16bd863b49fdd2bc28793b997a5783d0af4e03d6909e6222b2e2de8229
MD5 089659dff06ddfa42864538df0a51cef
BLAKE2b-256 c4c73b963095da0bff12f220fc5274dd5d5871585b1b2c57ae639ee37092a651

See more details on using hashes here.

File details

Details for the file pyroaring-0.3.1-cp38-cp38-macosx_10_14_x86_64.whl.

File metadata

  • Download URL: pyroaring-0.3.1-cp38-cp38-macosx_10_14_x86_64.whl
  • Upload date:
  • Size: 278.3 kB
  • Tags: CPython 3.8, macOS 10.14+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.8.10

File hashes

Hashes for pyroaring-0.3.1-cp38-cp38-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 1d0bc7fcf9d066383b3dd3837516c49ea7fd16f3eda58af380434ec66e23a5b1
MD5 5f5cb3d810a2787fe97cdd366a0a317f
BLAKE2b-256 361c8c3423b2f328c9ef82880955a4f2e3e4595e6655b4742218966ba6a8153b

See more details on using hashes here.

File details

Details for the file pyroaring-0.3.1-cp37-cp37m-win_amd64.whl.

File metadata

  • Download URL: pyroaring-0.3.1-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 205.9 kB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.7.9

File hashes

Hashes for pyroaring-0.3.1-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 b8c36dc2b226a316f77bc755c12472c77f435539262fb95444e752f5d1958275
MD5 a6626a7b4e8cef1a676662241f347260
BLAKE2b-256 1601cd5775f90a345077ad8ef0c7c7eb1db898926523a95878eabaedb479aa95

See more details on using hashes here.

File details

Details for the file pyroaring-0.3.1-cp37-cp37m-macosx_10_14_x86_64.whl.

File metadata

  • Download URL: pyroaring-0.3.1-cp37-cp37m-macosx_10_14_x86_64.whl
  • Upload date:
  • Size: 277.7 kB
  • Tags: CPython 3.7m, macOS 10.14+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.7.10

File hashes

Hashes for pyroaring-0.3.1-cp37-cp37m-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 1b7d18c64dad7d7ce5f5101c1c93ede228619443489e573baf62866ef1833824
MD5 30602d7e9331dbef08324f753e1d7e3a
BLAKE2b-256 3d5776cce38719628f5eac78c50d5849cb0969599cb9f57077ef6a127ca3728b

See more details on using hashes here.

File details

Details for the file pyroaring-0.3.1-cp36-cp36m-win_amd64.whl.

File metadata

  • Download URL: pyroaring-0.3.1-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 205.7 kB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.6.8

File hashes

Hashes for pyroaring-0.3.1-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 7cf8ec1779e9a11d2ab71ec60d0b56af13a76449dbe307fc74ece57bd758c26f
MD5 eff3f4e1baef2d4037408bdc018918eb
BLAKE2b-256 f1841d215c2447874a4acfad9d25c862fbafd96c3a21c5aea70dd5fac10f8ba0

See more details on using hashes here.

File details

Details for the file pyroaring-0.3.1-cp36-cp36m-macosx_10_14_x86_64.whl.

File metadata

  • Download URL: pyroaring-0.3.1-cp36-cp36m-macosx_10_14_x86_64.whl
  • Upload date:
  • Size: 277.3 kB
  • Tags: CPython 3.6m, macOS 10.14+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.6.13

File hashes

Hashes for pyroaring-0.3.1-cp36-cp36m-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 cdd71212d0a7a58f8073bc252afd36d14fd53c2b9f1542750ef06b3b4cbda818
MD5 9c0721b38568e8baa2cab54de308729b
BLAKE2b-256 d2c827e5f891bb4f0addfded0758c161ae410ab984b61d90c97ca48daae47f46

See more details on using hashes here.

File details

Details for the file pyroaring-0.3.1-cp35-cp35m-win_amd64.whl.

File metadata

  • Download URL: pyroaring-0.3.1-cp35-cp35m-win_amd64.whl
  • Upload date:
  • Size: 204.5 kB
  • Tags: CPython 3.5m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.7.0 requests/2.25.1 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.5.4

File hashes

Hashes for pyroaring-0.3.1-cp35-cp35m-win_amd64.whl
Algorithm Hash digest
SHA256 e4261a06cc5e3109ca968f99b3a8ee39894ad875ff64806be41c9599ae39ba2a
MD5 2a12507834fa873981221ee6b730a786
BLAKE2b-256 c6cfdafdff26c6fb63e9fef430c10d51cf054e4896bed0acea00f1a672959361

See more details on using hashes here.

File details

Details for the file pyroaring-0.3.1-cp35-cp35m-macosx_10_14_x86_64.whl.

File metadata

  • Download URL: pyroaring-0.3.1-cp35-cp35m-macosx_10_14_x86_64.whl
  • Upload date:
  • Size: 279.6 kB
  • Tags: CPython 3.5m, macOS 10.14+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.7.0 requests/2.25.1 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.5.10

File hashes

Hashes for pyroaring-0.3.1-cp35-cp35m-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 c57c1d62543338fedf2f59a31effcb927c3ca4dc1a423af72bb5b723ef4cc472
MD5 18ba00d32e4b1b03104629cb3066dbdf
BLAKE2b-256 daa908e3973b4b5187c6ef14614ff3945f73fd20c859c1c55a114523a0e195a3

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