{"id":17972999,"url":"https://github.com/jnyjny/bitvector","last_synced_at":"2025-07-07T00:35:54.502Z","repository":{"id":40681966,"uuid":"276520388","full_name":"JnyJny/bitvector","owner":"JnyJny","description":"Bit Vector for Humans™","archived":false,"fork":false,"pushed_at":"2024-07-17T15:06:55.000Z","size":77,"stargazers_count":9,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-20T08:44:54.941Z","etag":null,"topics":["bit-manipulation","bit-twiddling","bit-vector","for-humans","internet-of-things","iot","python","python3"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JnyJny.png","metadata":{"files":{"readme":"README.md","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}},"created_at":"2020-07-02T01:35:32.000Z","updated_at":"2024-07-17T15:06:59.000Z","dependencies_parsed_at":"2024-10-29T16:41:34.118Z","dependency_job_id":null,"html_url":"https://github.com/JnyJny/bitvector","commit_stats":{"total_commits":85,"total_committers":1,"mean_commits":85.0,"dds":0.0,"last_synced_commit":"6fb48affb1a28518bbd05c6aa148ac8a92bb318e"},"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JnyJny%2Fbitvector","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JnyJny%2Fbitvector/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JnyJny%2Fbitvector/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JnyJny%2Fbitvector/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JnyJny","download_url":"https://codeload.github.com/JnyJny/bitvector/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245463042,"owners_count":20619601,"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":["bit-manipulation","bit-twiddling","bit-vector","for-humans","internet-of-things","iot","python","python3"],"created_at":"2024-10-29T16:26:50.548Z","updated_at":"2025-07-07T00:35:54.486Z","avatar_url":"https://github.com/JnyJny.png","language":"Python","readme":"\u003c!-- python3 bitvector bit vector bits bit-twiddling binary --\u003e\n\n[![release][release-badge]][release]\n![version][pypi-version]\n![release date][release-date]\n![python version][python-version]\n![license][license]\n![code style: black][code-style-black]\n![monthly-downloads][monthly-downloads]\n\n\n\n# Bit Vectors For Humans™\n\nThis simple bit vector implementation aims to make addressing single\nbits a little less fiddly. It can be used by itself to work with bit\nfields in an integer word, but it really starts to shine when you use\nthe supplied `BitField` descriptor with a subclass of `BitVector`:\n\n```python\n\u003e from bitvector import BitVector, BitField\n\u003e\n\u003e class IOTDeviceCommand(BitVector):\n\u003e     def __init__(self):\n\u003e         super().__init__(size=32)\n\u003e\n\u003e     power = BitField(0, 1) # offset and size\n\u003e     spin  = BitField(1, 1)\n\u003e     speed = BitField(2, 4)\n\u003e     sense = BitField(6, 2)\n\u003e     red   = BitField(8, 8)\n\u003e     blue  = BitField(16, 8)\n\u003e     green = BitField(24, 8)\n\u003e\n\u003e widget_cmd = IOTDeviceCommand()\n\u003e widget_cmd.power = 1\n\u003e widget_cmd.sense = 2\n\u003e widget_cmd.speed = 5\n\u003e widget_cmd.red = 0xaa\n\u003e widget_cmd.blue = 0xbb\n\u003e widget_cmd.green = 0xcc\n\u003e widget_cmd\nIOTDeviceCommand(value=0xccbbaa95, size=32)\n\u003e widget_cmd.bytes\nb'\\xcc\\xbb\\xaa\\x95'\n```\n\n\n## Installation\n\n```console\n$ python3 -m pip install bitvector-for-humans\n$ pydoc bitvector\n...\n```\n\nOr directly from github:\n\n```console\n$ pip install git+https://github.com/JnyJny/bitvector.git\n```\n\n## Motivations\n\n1. Address sub-byte bits in a less error prone way.\n2. Minimize subdependencies (zero is minimized right?).\n3. Learn something about descriptors: ✅. \n\n## Caveats\n\nThe tests need expanding and I got lazy when writing the multi-bit\nsetting / getting code and it could undoubtedly be improved. Pull\nrequests gladly accepted.\n\n## Other Ways to Implement a Bit Vector\n\u003c!-- EJO add links to these other things --\u003e\n1. Python builtin `ctypes.Structure` allows sub-byte bit fields\n2. Python builtin `struct` provides extensive support for byte manipulations\n3. Python3 IntEnums can be used to build bit field masks\n4. The plain `int` will serve admirably with bitwise operators\n5. Provide cffi bindings to existing bit-twiddling libraries\n6. Use Numpy bool arrays as the \"backing store\"\n7. Other good ideas I overlooked, forgot about or just plain don't know.\n\n\n\u003c!-- badges --\u003e\n[release-badge]: https://github.com/JnyJny/bitvector/actions/workflows/release.yaml/badge.svg\n[release]: https://github.com/JnyJny/bitvector/actions/workflows/release.yaml\n[pypi-version]: https://img.shields.io/pypi/v/bitvector-for-humans\n[release-date]: https://img.shields.io/github/release-date/JnyJny/bitvector\n[python-version]: https://img.shields.io/python/required-version-toml?tomlFilePath=https%3A%2F%2Fraw.githubusercontent.com%2FJnyJny%2Fbitvector%2Frefs%2Fheads%2Fmaster%2Fpyproject.toml\n\n[license]: https://img.shields.io/pypi/l/bitvector-for-humans\n[code-style-black]: https://img.shields.io/badge/code%20style-black-000000.svg\n[monthly-downloads]: https://img.shields.io/pypi/dm/bitvector-for-humans\n\n\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjnyjny%2Fbitvector","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjnyjny%2Fbitvector","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjnyjny%2Fbitvector/lists"}