{"id":21453456,"url":"https://github.com/lapets/bitlist","last_synced_at":"2025-10-09T19:05:12.494Z","repository":{"id":49716933,"uuid":"81679685","full_name":"lapets/bitlist","owner":"lapets","description":"Pure-Python library for working with bit vectors.","archived":false,"fork":false,"pushed_at":"2025-04-25T05:52:55.000Z","size":87,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-01T10:54:36.313Z","etag":null,"topics":["bit","bit-algorithms","bit-array","bit-manipulation","bit-vector","bit-vectors","bits","bitvector","common-library","data-structures","python"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/bitlist","language":"Python","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/lapets.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":"2017-02-11T20:19:17.000Z","updated_at":"2025-04-25T05:52:59.000Z","dependencies_parsed_at":"2025-04-25T06:40:55.013Z","dependency_job_id":null,"html_url":"https://github.com/lapets/bitlist","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/lapets/bitlist","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lapets%2Fbitlist","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lapets%2Fbitlist/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lapets%2Fbitlist/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lapets%2Fbitlist/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lapets","download_url":"https://codeload.github.com/lapets/bitlist/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lapets%2Fbitlist/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268675515,"owners_count":24288285,"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","status":"online","status_checked_at":"2025-08-04T02:00:09.867Z","response_time":79,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["bit","bit-algorithms","bit-array","bit-manipulation","bit-vector","bit-vectors","bits","bitvector","common-library","data-structures","python"],"created_at":"2024-11-23T04:39:41.930Z","updated_at":"2025-10-09T19:05:12.489Z","avatar_url":"https://github.com/lapets.png","language":"Python","readme":"=======\nbitlist\n=======\n\nPure-Python library for working with bit vectors.\n\n|pypi| |readthedocs| |actions| |coveralls|\n\n.. |pypi| image:: https://badge.fury.io/py/bitlist.svg#\n   :target: https://badge.fury.io/py/bitlist\n   :alt: PyPI version and link.\n\n.. |readthedocs| image:: https://readthedocs.org/projects/bitlist/badge/?version=latest\n   :target: https://bitlist.readthedocs.io/en/latest/?badge=latest\n   :alt: Read the Docs documentation status.\n\n.. |actions| image:: https://github.com/lapets/bitlist/workflows/lint-test-cover-docs/badge.svg#\n   :target: https://github.com/lapets/bitlist/actions/workflows/lint-test-cover-docs.yml\n   :alt: GitHub Actions status.\n\n.. |coveralls| image:: https://coveralls.io/repos/github/lapets/bitlist/badge.svg?branch=main\n   :target: https://coveralls.io/github/lapets/bitlist?branch=main\n   :alt: Coveralls test coverage summary.\n\nPurpose\n-------\nThis library allows programmers to work with bit vectors using a pure-Python data structure. Its design prioritizes interoperability with built-in Python classes and operators.\n\nInstallation and Usage\n----------------------\nThis library is available as a `package on PyPI \u003chttps://pypi.org/project/bitlist\u003e`__:\n\n.. code-block:: bash\n\n    python -m pip install bitlist\n\nThe library can be imported in the usual manner:\n\n.. code-block:: python\n\n    import bitlist\n    from bitlist import bitlist\n\nExamples\n^^^^^^^^\n\n.. |bitlist| replace:: ``bitlist``\n.. _bitlist: https://bitlist.readthedocs.io/en/2.0.0/_source/bitlist.html#bitlist.bitlist.bitlist\n\nThis library makes it possible to construct bit vectors from a variety of representations (including integers, bytes-like objects, strings of binary digits, lists of binary digits, and other bit vectors). Integer arguments are converted into a big-endian binary representation:\n\n.. code-block:: python\n\n    \u003e\u003e\u003e bitlist(123)\n    bitlist('1111011')\n    \u003e\u003e\u003e bitlist(bytes([255, 254]))\n    bitlist('1111111111111110')\n    \u003e\u003e\u003e bitlist('101')\n    bitlist('101')\n    \u003e\u003e\u003e bitlist([1, 0, 1, 1])\n    bitlist('1011')\n    \u003e\u003e\u003e bitlist(bitlist('1010'))\n    bitlist('1010')\n\nThe optional ``length`` parameter can be used to specify the length of the created bit vector (padding consisting of zero bits is applied automatically *on the left-hand size*, if necessary):\n\n.. code-block:: python\n\n    \u003e\u003e\u003e bitlist(bytes([123]), length=16)\n    bitlist('0000000001111011')\n    \u003e\u003e\u003e bitlist(16, 64)\n    bitlist('0000000000000000000000000000000000000000000000000000000000010000')\n    \u003e\u003e\u003e bitlist(bitlist(123), 8)\n    bitlist('01111011')\n\nIf the ``length`` parameter has a value that is less than the minimum number of bits that would be included according to the default constructor behaviors, the bit vector is truncated *on the left-hand side* to match the specified length:\n\n.. code-block:: python\n\n    \u003e\u003e\u003e bitlist(bytes([123]), length=7)\n    bitlist('1111011')\n    \u003e\u003e\u003e bitlist(bytes([123]), 4)\n    bitlist('1011')\n    \u003e\u003e\u003e bitlist(bytes([123]), 2)\n    bitlist('11')\n    \u003e\u003e\u003e bitlist(bytes([123]), 0)\n    bitlist()\n\nBit vectors are iterable sequences of individual bits (where each bit is represented as an integer). Both slice notation and retrieval of individual bits by index are supported. Furthermore, methods are available for converting a bit vector into other common representations:\n\n.. code-block:: python\n\n    \u003e\u003e\u003e b = bitlist('1111011')\n    \u003e\u003e\u003e b[1:-1]\n    bitlist('11101')\n    \u003e\u003e\u003e b[0]\n    1\n    \u003e\u003e\u003e [bit for bit in b]\n    [1, 1, 1, 1, 0, 1, 1]\n    \u003e\u003e\u003e b.bin()\n    '1111011'\n    \u003e\u003e\u003e b.hex()\n    '7b'\n    \u003e\u003e\u003e list(b.to_bytes())\n    [123]\n\n`Concatenation \u003chttps://bitlist.readthedocs.io/en/2.0.0/_source/bitlist.html#bitlist.bitlist.bitlist.__add__\u003e`__, `partitioning \u003chttps://bitlist.readthedocs.io/en/2.0.0/_source/bitlist.html#bitlist.bitlist.bitlist.__truediv__\u003e`__, `subscription and slicing \u003chttps://bitlist.readthedocs.io/en/2.0.0/_source/bitlist.html#bitlist.bitlist.bitlist.__getitem__\u003e`__, `shift and rotation \u003chttps://bitlist.readthedocs.io/en/2.0.0/_source/bitlist.html#bitlist.bitlist.bitlist.__lshift__\u003e`__, `comparison \u003chttps://bitlist.readthedocs.io/en/2.0.0/_source/bitlist.html#bitlist.bitlist.bitlist.__eq__\u003e`__, and `logical \u003chttps://bitlist.readthedocs.io/en/2.0.0/_source/bitlist.html#bitlist.bitlist.bitlist.__and__\u003e`__ operations are also supported by instances of the |bitlist|_ class. The larger example below -- a bitwise addition function -- illustrates the use of various operators supported by instances of the |bitlist|_ class:\n\n.. code-block:: python\n\n    \u003e\u003e\u003e def add(x, y):\n    ...     \"\"\"Bitwise addition algorithm.\"\"\"\n    ...     r = bitlist(0)\n    ...     carry = 0\n    ...     # Use negative indices for big-endian interface.\n    ...     for i in range(1, max(len(x), len(y)) + 1):\n    ...         r[-i] = (x[-i] ^ y[-i]) ^ carry\n    ...         carry = (x[-i] \u0026 y[-i]) | (x[-i] \u0026 carry) | (y[-i] \u0026 carry)\n    ...     r[-(max(len(x), len(y)) + 1)] = carry\n    ...     return r\n    ...\n    \u003e\u003e\u003e int(add(bitlist(123), bitlist(456)))\n    579\n\nThe `testing script \u003chttps://bitlist.readthedocs.io/en/2.0.0/_source/test_bitlist.html\u003e`__ that accompanies this library contains additional examples of bitwise arithmetic operations implemented with the help of |bitlist|_ operators.\n\nDevelopment\n-----------\nAll installation and development dependencies are fully specified in ``pyproject.toml``. The ``project.optional-dependencies`` object is used to `specify optional requirements \u003chttps://peps.python.org/pep-0621\u003e`__ for various development tasks. This makes it possible to specify additional options (such as ``docs``, ``lint``, and so on) when performing installation using `pip \u003chttps://pypi.org/project/pip\u003e`__:\n\n.. code-block:: bash\n\n    python -m pip install \".[docs,lint]\"\n\nDocumentation\n^^^^^^^^^^^^^\nThe documentation can be generated automatically from the source files using `Sphinx \u003chttps://www.sphinx-doc.org\u003e`__:\n\n.. code-block:: bash\n\n    python -m pip install \".[docs]\"\n    cd docs\n    sphinx-apidoc -f -E --templatedir=_templates -o _source .. \u0026\u0026 make html\n\nTesting and Conventions\n^^^^^^^^^^^^^^^^^^^^^^^\nAll unit tests are executed and their coverage is measured when using `pytest \u003chttps://docs.pytest.org\u003e`__ (see the ``pyproject.toml`` file for configuration details):\n\n.. code-block:: bash\n\n    python -m pip install \".[test]\"\n    python -m pytest\n\nThe subset of the unit tests included in the module itself and the *documentation examples* that appear in the testing script can be executed separately using `doctest \u003chttps://docs.python.org/3/library/doctest.html\u003e`__:\n\n.. code-block:: bash\n\n    python src/bitlist/bitlist.py -v\n    python test/test_bitlist.py -v\n\nStyle conventions are enforced using `Pylint \u003chttps://pylint.readthedocs.io\u003e`__:\n\n.. code-block:: bash\n\n    python -m pip install \".[lint]\"\n    python -m pylint src/bitlist test/test_bitlist.py\n\nContributions\n^^^^^^^^^^^^^\nIn order to contribute to the source code, open an issue or submit a pull request on the `GitHub page \u003chttps://github.com/lapets/bitlist\u003e`__ for this library.\n\nVersioning\n^^^^^^^^^^\nBeginning with version 0.3.0, the version number format for this library and the changes to the library associated with version number increments conform with `Semantic Versioning 2.0.0 \u003chttps://semver.org/#semantic-versioning-200\u003e`__.\n\nPublishing\n^^^^^^^^^^\nThis library can be published as a `package on PyPI \u003chttps://pypi.org/project/bitlist\u003e`__ via the GitHub Actions workflow found in ``.github/workflows/build-publish-sign-release.yml`` that follows the `recommendations found in the Python Packaging User Guide \u003chttps://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/\u003e`__.\n\nEnsure that the correct version number appears in ``pyproject.toml``, and that any links in this README document to the Read the Docs documentation of this package (or its dependencies) have appropriate version numbers. Also ensure that the Read the Docs project for this library has an `automation rule \u003chttps://docs.readthedocs.io/en/stable/automation-rules.html\u003e`__ that activates and sets as the default all tagged versions.\n\nTo publish the package, create and push a tag for the version being published (replacing ``?.?.?`` with the version number):\n\n.. code-block:: bash\n\n    git tag ?.?.?\n    git push origin ?.?.?\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flapets%2Fbitlist","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flapets%2Fbitlist","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flapets%2Fbitlist/lists"}