{"id":13936195,"url":"https://github.com/Ezibenroc/PyRoaringBitMap","last_synced_at":"2025-07-19T21:32:02.080Z","repository":{"id":55012976,"uuid":"58303578","full_name":"Ezibenroc/PyRoaringBitMap","owner":"Ezibenroc","description":"Python library for handling efficiently sorted integer sets.","archived":false,"fork":false,"pushed_at":"2025-06-28T20:53:44.000Z","size":4902,"stargazers_count":211,"open_issues_count":5,"forks_count":32,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-06-28T21:20:43.658Z","etag":null,"topics":["bitset","python","roaring-bitmaps"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Ezibenroc.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2016-05-08T08:38:29.000Z","updated_at":"2025-06-25T21:13:49.000Z","dependencies_parsed_at":"2023-02-05T18:32:17.272Z","dependency_job_id":"e6dba604-d018-4f09-9050-c569ffb5f3c4","html_url":"https://github.com/Ezibenroc/PyRoaringBitMap","commit_stats":{"total_commits":346,"total_committers":17,"mean_commits":"20.352941176470587","dds":0.5780346820809248,"last_synced_commit":"7eb7330d8a474456231572417e951babac4a3576"},"previous_names":[],"tags_count":53,"template":false,"template_full_name":null,"purl":"pkg:github/Ezibenroc/PyRoaringBitMap","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ezibenroc%2FPyRoaringBitMap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ezibenroc%2FPyRoaringBitMap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ezibenroc%2FPyRoaringBitMap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ezibenroc%2FPyRoaringBitMap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Ezibenroc","download_url":"https://codeload.github.com/Ezibenroc/PyRoaringBitMap/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ezibenroc%2FPyRoaringBitMap/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266019657,"owners_count":23864916,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bitset","python","roaring-bitmaps"],"created_at":"2024-08-07T23:02:27.680Z","updated_at":"2025-07-19T21:31:57.071Z","avatar_url":"https://github.com/Ezibenroc.png","language":"C","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"|Documentation Status|\n\nAn efficient and light-weight ordered set of integers.\nThis is a Python wrapper for the C library `CRoaring \u003chttps://github.com/RoaringBitmap/CRoaring\u003e`__.\n\nExample\n-------\n\nYou can use a bitmap nearly as the classical Python set in your code:\n\n.. code:: python\n\n    from pyroaring import BitMap\n    bm1 = BitMap()\n    bm1.add(3)\n    bm1.add(18)\n    print(\"has 3:\", 3 in bm1)\n    print(\"has 4:\", 4 in bm1)\n    bm2 = BitMap([3, 27, 42])\n    print(\"bm1       = %s\" % bm1)\n    print(\"bm2       = %s\" % bm2)\n    print(\"bm1 \u0026 bm2 = %s\" % (bm1\u0026bm2))\n    print(\"bm1 | bm2 = %s\" % (bm1|bm2))\n\nOutput:\n\n::\n\n    has 3: True\n    has 4: False\n    bm1       = BitMap([3, 18])\n    bm2       = BitMap([3, 27, 42])\n    bm1 \u0026 bm2 = BitMap([3])\n    bm1 | bm2 = BitMap([3, 18, 27, 42])\n\nThe class ``BitMap`` is for 32 bit integers, it supports values from 0 to 2**32-1 (included).\n\nFor larger numbers, you can use the class ``BitMap64`` that supports values from 0 to 2**64-1 (included).\n\nInstallation from Pypi\n----------------------\n\nSupported systems: Linux, MacOS or Windows, Python 3.8 or higher. Note that pyroaring might still work with older Python\nversions, but they are not tested anymore.\n\nTo install pyroaring on your local account, use the following command:\n\n.. code:: bash\n\n    pip install pyroaring --user\n\nFor a system-wide installation, use the following command:\n\n.. code:: bash\n\n    pip install pyroaring\n\nNaturally, the latter may require superuser rights (consider prefixing\nthe commands by ``sudo``).\n\nIf you want to use Python 3 and your system defaults on Python 2.7, you\nmay need to adjust the above commands, e.g., replace ``pip`` by ``pip3``.\n\nInstallation from conda-forge\n-----------------------------\n\nConda users can install the package from `conda-forge`:\n\n.. code:: bash\n\n   conda install -c conda-forge pyroaring\n\n(Supports Python 3.6 or higher; Mac/Linux/Windows)\n\nInstallation from Source\n---------------------------------\n\nIf you want to compile (and install) pyroaring by yourself, for instance\nto modify the Cython sources you can follow the following instructions.\nNote that these examples will install in your currently active python\nvirtual environment. Installing this way will require an appropriate\nC compiler to be installed on your system.\n\nFirst clone this repository.\n\n.. code:: bash\n\n    git clone https://github.com/Ezibenroc/PyRoaringBitMap.git\n\nTo install from Cython via source, for example during development run the following from the root of the above repository:\n\n.. code:: bash\n\n    python -m pip install .\n\nThis will automatically install Cython if it not present for the build, cythonise the source files and compile everything for you.\n\nIf you just want to recompile the package in place for quick testing you can\ntry the following:\n\n.. code:: bash\n\n    python setup.py build_clib\n    python setup.py build_ext -i\n\nNote that the build_clib compiles croaring only, and only needs to be run once.\n\nThen you can test the new code using tox - this will install all the other\ndependencies needed for testing and test in an isolated environment:\n\n.. code:: bash\n\n    python -m pip install tox\n    tox\n\nIf you just want to run the tests directly from the root of the repository:\n\n.. code:: bash\n\n    python -m pip install hypothesis pytest\n    # This will test in three ways: via installation from source,\n    # via cython directly, and creation of a wheel\n    python -m pytest test.py\n\n\nPackage pyroaring as an sdist and wheel. Note that building wheels that have\nwide compatibility can be tricky - for releases we rely on `cibuildwheel \u003chttps://cibuildwheel.readthedocs.io/en/stable/\u003e`_\nto do the heavy lifting across platforms.\n\n.. code:: bash\n\n    python -m pip install build\n    python -m build .\n\nFor all the above commands, two environment variables can be used to control the compilation.\n\n- ``DEBUG=1`` to build pyroaring in debug mode.\n- ``ARCHI=\u003ccpu-type\u003e`` to build pyroaring for the given platform. The platform may be any keyword\n  given to the ``-march`` option of gcc (see the\n  `documentation \u003chttps://gcc.gnu.org/onlinedocs/gcc-4.5.3/gcc/i386-and-x86_002d64-Options.html\u003e`__).\n  Note that cross-compiling for a 32-bit architecture from a 64-bit architecture is not supported.\n\nExample of use:\n\n.. code:: bash\n\n    DEBUG=1 ARCHI=x86-64 python setup.py build_ext\n\n\nOptimizing the builds for your machine (x64)\n--------------------------------------------\n\nFor recent Intel and AMD (x64) processors under Linux, you may get better performance by requesting that\nCRoaring be built for your machine, specifically, when building from source.\nBe mindful that when doing so, the generated binary may only run on your machine.\n\n\n.. code:: bash\n\n    ARCHI=native pip install pyroaring  --no-binary :all:\n\nThis approach may not work under macOS.\n\n\nDevelopment Notes\n-----------------\n\nUpdating CRoaring\n=================\n\nThe download_amalgamation.py script can be used to download a specific version\nof the official CRoaring amalgamation:\n\n.. code:: bash\n\n    python download_amalgamation.py v0.7.2\n\nThis will update roaring.c and roaring.h. This also means that the dependency\nis vendored in and tracked as part of the source repository now. Note that the\n__croaring_version__ in version.pxi will need to be updated to match the new\nversion.\n\n\nTracking Package and CRoaring versions\n======================================\n\nThe package version is maintained in the file `pyroaring/version.pxi` - this\ncan be manually incremented in preparation for releases. This file is read\nfrom in setup.py to specify the version.\n\nThe croaring version is tracked in `pyroaring/croaring_version.pxi` - this is\nupdated automatically when downloading a new amalgamation.\n\n\nBenchmark\n---------\n\n``Pyroaring`` is compared with the built-in ``set`` and the library ``sortedcontainers``.\n\nThe script ``quick_bench.py`` measures the time of different set\noperations. It uses randomly generated sets of size 1e6 and density\n0.125. For each operation, the average time (in seconds) of 30 tests\nis reported.\n\nThe results have been obtained with:\n\n- CPU AMD Ryzen 7 5700X\n- CPython version 3.11.2\n- gcc version 12.2.0\n- Cython version 3.0.2\n- sortedcontainers version 2.4.0\n- pyroaring commit `b54769b \u003chttps://github.com/Ezibenroc/PyRoaringBitMap/tree/b54769bf22b037ed989348b04d297ddc56db7ed8\u003e`__\n\n===============================  =====================  =====================  ==========  ==================\noperation                          pyroaring (32 bits)    pyroaring (64 bits)         set    sortedcontainers\n===============================  =====================  =====================  ==========  ==================\nrange constructor                             3.03e-04               3.15e-04    4.09e-02            8.54e-02\nordered list constructor                      2.17e-02               3.06e-02    8.21e-02            2.67e-01\nlist constructor                              7.23e-02               6.38e-02    5.65e-02            2.34e-01\nordered array constructor                     4.50e-03             nan           6.53e-02            1.75e-01\narray constructor                             6.51e-02             nan           8.98e-02            2.40e-01\nelement addition                              4.33e-07               2.19e-07    2.13e-07            3.82e-07\nelement removal                               2.69e-07               1.67e-07    2.33e-07            2.83e-07\nmembership test                               1.59e-07               1.33e-07    1.42e-07            3.22e-07\nunion                                         1.07e-04               1.04e-04    1.06e-01            5.69e-01\nintersection                                  6.00e-04               6.26e-04    4.66e-02            1.03e-01\ndifference                                    7.24e-05               8.34e-05    7.94e-02            2.34e-01\nsymmetric diference                           8.32e-05               1.03e-04    1.31e-01            4.19e-01\nequality test                                 3.52e-05               3.21e-05    3.18e-02            3.29e-02\nsubset test                                   4.15e-05               4.41e-05    3.20e-02            3.20e-02\nconversion to list                            2.92e-02               3.08e-02    3.16e-02            3.53e-02\npickle dump \u0026 load                            1.64e-04               1.76e-04    1.37e-01            3.53e-01\n\"naive\" conversion to array                   2.46e-02               2.57e-02    6.49e-02            5.73e-02\n\"optimized\" conversion to array               8.73e-04               1.45e-03  nan                 nan\nselection                                     8.83e-07               2.49e-06  nan                   8.18e-06\ncontiguous slice                              3.31e-03               6.49e-03  nan                   4.32e-03\nslice                                         1.58e-03               2.74e-03  nan                   1.29e-01\nsmall slice                                   6.62e-05               1.15e-04  nan                   5.43e-03\n===============================  =====================  =====================  ==========  ==================\n\nNote: the timings are missing for pyroaring 64 bits with the array constructor. For simplicity reasons the Benchmark\nbuilds an array of 32 bit integers, which is not compatible with ``BitMap64``.\n\n.. |Documentation Status| image:: https://readthedocs.org/projects/pyroaringbitmap/badge/?version=stable\n   :target: http://pyroaringbitmap.readthedocs.io/en/stable/?badge=stable\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FEzibenroc%2FPyRoaringBitMap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FEzibenroc%2FPyRoaringBitMap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FEzibenroc%2FPyRoaringBitMap/lists"}