Name | bitstring JSON |
Version |
4.3.0
JSON |
| download |
home_page | None |
Summary | Simple construction, analysis and modification of binary data. |
upload_time | 2025-01-01 13:25:13 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.8 |
license | None |
keywords |
binary
bitarray
bitvector
bitfield
|
VCS |
 |
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|

**bitstring** is a Python library to help make the creation and analysis of all types of bit-level binary data as simple and efficient as possible. It has been actively maintained since 2006.
The library has has now been downloaded over 100 million times! ✨ [](https://www.pepy.tech/projects/bitstring) ✨
[](https://github.com/scott-griffiths/bitstring/actions/workflows/ci.yml)
[](https://bitstring.readthedocs.io/en/latest/)
[](https://app.codacy.com/gh/scott-griffiths/bitstring/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade)
[](https://libraries.io/pypi/bitstring)
[](https://www.pepy.tech/projects/bitstring)
[](https://pypistats.org/packages/bitstring)
----
> [!NOTE]
> To see what been added, improved or fixed, and also to see what's coming in the next version, see the [release notes](https://github.com/scott-griffiths/bitstring/blob/main/release_notes.md).
# Overview
* Efficiently store and manipulate binary data in idiomatic Python.
* Create bitstrings from hex, octal, binary, files, formatted strings, bytes, integers and floats of different endiannesses.
* Powerful binary packing and unpacking functions.
* Bit-level slicing, joining, searching, replacing and more.
* Create and manipulate arrays of fixed-length bitstrings.
* Read from and interpret bitstrings as streams of binary data.
* Rich API - chances are that whatever you want to do there's a simple and elegant way of doing it.
* Open source software, released under the MIT licence.
# Documentation
Extensive documentation for the bitstring library is available.
Some starting points are given below:
* [Overview](https://bitstring.readthedocs.io/en/stable/index.html)
* [Quick Reference](https://bitstring.readthedocs.io/en/stable/quick_reference.html)
* [Full Reference](https://bitstring.readthedocs.io/en/stable/reference.html)
There is also an introductory walkthrough notebook on [binder](https://mybinder.org/v2/gh/scott-griffiths/bitstring/main?labpath=doc%2Fwalkthrough.ipynb).
# Examples
### Installation
```
$ pip install bitstring
```
### Creation
```pycon
>>> from bitstring import Bits, BitArray, BitStream, pack
>>> a = BitArray(bin='00101')
>>> b = Bits(a_file_object)
>>> c = BitArray('0xff, 0b101, 0o65, uint6=22')
>>> d = pack('intle16, hex=a, 0b1', 100, a='0x34f')
>>> e = pack('<16h', *range(16))
```
### Different interpretations, slicing and concatenation
```pycon
>>> a = BitArray('0x3348')
>>> a.hex, a.bin, a.uint, a.float, a.bytes
('3348', '0011001101001000', 13128, 0.2275390625, b'3H')
>>> a[10:3:-1].bin
'0101100'
>>> '0b100' + 3*a
BitArray('0x866906690669, 0b000')
```
### Reading data sequentially
```pycon
>>> b = BitStream('0x160120f')
>>> b.read(12).hex
'160'
>>> b.pos = 0
>>> b.read('uint12')
352
>>> b.readlist('uint12, bin3')
[288, '111']
```
### Searching, inserting and deleting
```pycon
>>> c = BitArray('0b00010010010010001111') # c.hex == '0x1248f'
>>> c.find('0x48')
(8,)
>>> c.replace('0b001', '0xabc')
>>> c.insert('0b0000', pos=3)
>>> del c[12:16]
```
### Arrays of fixed-length formats
```pycon
>>> from bitstring import Array
>>> a = Array('uint7', [9, 100, 3, 1])
>>> a.data
BitArray('0x1390181')
>>> a[::2] *= 5
>>> a
Array('uint7', [45, 100, 15, 1])
```
<sub>Copyright (c) 2006 - 2025 Scott Griffiths</sub>
Raw data
{
"_id": null,
"home_page": null,
"name": "bitstring",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "binary, bitarray, bitvector, bitfield",
"author": null,
"author_email": "Scott Griffiths <dr.scottgriffiths@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/0d/43/52859178f337661e2d496262f9061799d99644012b7b02ab5d7c491c21fd/bitstring-4.3.0.tar.gz",
"platform": null,
"description": "\n\n\n\n**bitstring** is a Python library to help make the creation and analysis of all types of bit-level binary data as simple and efficient as possible. It has been actively maintained since 2006.\n\nThe library has has now been downloaded over 100 million times! \u2728 [](https://www.pepy.tech/projects/bitstring) \u2728\n\n\n\n[](https://github.com/scott-griffiths/bitstring/actions/workflows/ci.yml)\n[](https://bitstring.readthedocs.io/en/latest/)\n[](https://app.codacy.com/gh/scott-griffiths/bitstring/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade)\n[](https://libraries.io/pypi/bitstring)\n \n[](https://www.pepy.tech/projects/bitstring)\n[](https://pypistats.org/packages/bitstring)\n\n----\n\n> [!NOTE]\n> To see what been added, improved or fixed, and also to see what's coming in the next version, see the [release notes](https://github.com/scott-griffiths/bitstring/blob/main/release_notes.md).\n\n\n# Overview\n\n* Efficiently store and manipulate binary data in idiomatic Python.\n* Create bitstrings from hex, octal, binary, files, formatted strings, bytes, integers and floats of different endiannesses.\n* Powerful binary packing and unpacking functions.\n* Bit-level slicing, joining, searching, replacing and more.\n* Create and manipulate arrays of fixed-length bitstrings.\n* Read from and interpret bitstrings as streams of binary data.\n* Rich API - chances are that whatever you want to do there's a simple and elegant way of doing it.\n* Open source software, released under the MIT licence.\n\n# Documentation\n\nExtensive documentation for the bitstring library is available.\nSome starting points are given below:\n\n* [Overview](https://bitstring.readthedocs.io/en/stable/index.html)\n* [Quick Reference](https://bitstring.readthedocs.io/en/stable/quick_reference.html)\n* [Full Reference](https://bitstring.readthedocs.io/en/stable/reference.html)\n\nThere is also an introductory walkthrough notebook on [binder](https://mybinder.org/v2/gh/scott-griffiths/bitstring/main?labpath=doc%2Fwalkthrough.ipynb).\n\n# Examples\n\n### Installation\n```\n$ pip install bitstring\n```\n\n### Creation\n```pycon\n>>> from bitstring import Bits, BitArray, BitStream, pack\n>>> a = BitArray(bin='00101')\n>>> b = Bits(a_file_object)\n>>> c = BitArray('0xff, 0b101, 0o65, uint6=22')\n>>> d = pack('intle16, hex=a, 0b1', 100, a='0x34f')\n>>> e = pack('<16h', *range(16))\n```\n\n### Different interpretations, slicing and concatenation\n```pycon\n>>> a = BitArray('0x3348')\n>>> a.hex, a.bin, a.uint, a.float, a.bytes\n('3348', '0011001101001000', 13128, 0.2275390625, b'3H')\n>>> a[10:3:-1].bin\n'0101100'\n>>> '0b100' + 3*a\nBitArray('0x866906690669, 0b000')\n```\n\n### Reading data sequentially\n```pycon\n>>> b = BitStream('0x160120f')\n>>> b.read(12).hex\n'160'\n>>> b.pos = 0\n>>> b.read('uint12')\n352\n>>> b.readlist('uint12, bin3')\n[288, '111']\n```\n\n### Searching, inserting and deleting\n```pycon\n>>> c = BitArray('0b00010010010010001111') # c.hex == '0x1248f'\n>>> c.find('0x48')\n(8,)\n>>> c.replace('0b001', '0xabc')\n>>> c.insert('0b0000', pos=3)\n>>> del c[12:16]\n```\n\n### Arrays of fixed-length formats\n```pycon\n>>> from bitstring import Array\n>>> a = Array('uint7', [9, 100, 3, 1])\n>>> a.data\nBitArray('0x1390181')\n>>> a[::2] *= 5\n>>> a\nArray('uint7', [45, 100, 15, 1])\n```\n\n\n<sub>Copyright (c) 2006 - 2025 Scott Griffiths</sub>\n",
"bugtrack_url": null,
"license": null,
"summary": "Simple construction, analysis and modification of binary data.",
"version": "4.3.0",
"project_urls": {
"documentation": "https://bitstring.readthedocs.io/",
"homepage": "https://github.com/scott-griffiths/bitstring"
},
"split_keywords": [
"binary",
" bitarray",
" bitvector",
" bitfield"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "c3e2ffb466d2325eba94fcae18df609605b99d454b3855491d7bf1023c473911",
"md5": "b3f1ea9708cd868c4e51d94ec0d30fda",
"sha256": "3282a896814813f8fe5fa09dbafac842c57aace1d3bfd94546c6f1ed9aafcbe1"
},
"downloads": -1,
"filename": "bitstring-4.3.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "b3f1ea9708cd868c4e51d94ec0d30fda",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 71889,
"upload_time": "2025-01-01T13:25:09",
"upload_time_iso_8601": "2025-01-01T13:25:09.701129Z",
"url": "https://files.pythonhosted.org/packages/c3/e2/ffb466d2325eba94fcae18df609605b99d454b3855491d7bf1023c473911/bitstring-4.3.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "0d4352859178f337661e2d496262f9061799d99644012b7b02ab5d7c491c21fd",
"md5": "378cfff7d1c8befad689cc6df0e642b7",
"sha256": "81800bc4e00b6508716adbae648e741256355c8dfd19541f76482fb89bee0313"
},
"downloads": -1,
"filename": "bitstring-4.3.0.tar.gz",
"has_sig": false,
"md5_digest": "378cfff7d1c8befad689cc6df0e642b7",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 251408,
"upload_time": "2025-01-01T13:25:13",
"upload_time_iso_8601": "2025-01-01T13:25:13.068144Z",
"url": "https://files.pythonhosted.org/packages/0d/43/52859178f337661e2d496262f9061799d99644012b7b02ab5d7c491c21fd/bitstring-4.3.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-01-01 13:25:13",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "scott-griffiths",
"github_project": "bitstring",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "bitstring"
}