bitstring


Namebitstring JSON
Version 4.2.1 PyPI version JSON
download
home_pageNone
SummarySimple construction, analysis and modification of binary data.
upload_time2024-04-24 19:49:54
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseNone
keywords binary bitarray bitvector bitfield
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            

![bitstring](https://raw.githubusercontent.com/scott-griffiths/bitstring/main/doc/bitstring_logo_small.png "bitstring")

**bitstring** is a Python module 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.



[![CI badge](https://github.com/scott-griffiths/bitstring/actions/workflows/.github/workflows/ci.yml/badge.svg)](https://github.com/scott-griffiths/bitstring/actions/workflows/ci.yml)
[![Docs](https://img.shields.io/readthedocs/bitstring?logo=readthedocs&logoColor=white)](https://bitstring.readthedocs.io/en/latest/)
[![Codacy Badge](https://img.shields.io/codacy/grade/8869499b2eed44548fa1a5149dd451f4?logo=codacy)](https://app.codacy.com/gh/scott-griffiths/bitstring/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade)
[![Dependents (via libraries.io)](https://img.shields.io/librariesio/dependents/pypi/bitstring?logo=libraries.io&logoColor=white)](https://libraries.io/pypi/bitstring)
   
[![Pepy Total Downlods](https://img.shields.io/pepy/dt/bitstring?logo=python&logoColor=white&labelColor=blue&color=blue)](https://www.pepy.tech/projects/bitstring)
[![PyPI - Downloads](https://img.shields.io/pypi/dm/bitstring?label=%40&labelColor=blue&color=blue)](https://pypistats.org/packages/bitstring)


News
----
**April 2024**: bitstring 4.2.1 released.
 
New in version 4.2:

* Dropped support for Python 3.7. Minimum version is now 3.8.
* A new `Dtype` class can be optionally used to specify types.
* The `bitstring.options` object is now the preferred method for changing module options.
* New `fromstring` method as another way to create bitstrings from formatted strings.
* More types can now be pretty printed.
* A range of 8-bit, 6-bit and even 4-bit floating point formats added (beta):
* Performance improvements.

See the [release notes](https://github.com/scott-griffiths/bitstring/blob/main/release_notes.txt) for details. Please let me know if you encounter any problems.


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 module 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).

Release Notes
-------------

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.txt).

Examples
--------

### Installation

    $ pip install bitstring

### Creation

     >>> 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

     >>> 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

     >>> 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

     >>> 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

     >>> 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 - 2024 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/eb/57/699428f6ab4c0863f8555d80ffceb3e7b385622cefdcebe5264121349986/bitstring-4.2.1.tar.gz",
    "platform": null,
    "description": "\n\n![bitstring](https://raw.githubusercontent.com/scott-griffiths/bitstring/main/doc/bitstring_logo_small.png \"bitstring\")\n\n**bitstring** is a Python module to help make the creation and analysis of all types of bit-level binary data as simple and efficient as possible.\n\nIt has been actively maintained since 2006.\n\n\n\n[![CI badge](https://github.com/scott-griffiths/bitstring/actions/workflows/.github/workflows/ci.yml/badge.svg)](https://github.com/scott-griffiths/bitstring/actions/workflows/ci.yml)\n[![Docs](https://img.shields.io/readthedocs/bitstring?logo=readthedocs&logoColor=white)](https://bitstring.readthedocs.io/en/latest/)\n[![Codacy Badge](https://img.shields.io/codacy/grade/8869499b2eed44548fa1a5149dd451f4?logo=codacy)](https://app.codacy.com/gh/scott-griffiths/bitstring/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade)\n[![Dependents (via libraries.io)](https://img.shields.io/librariesio/dependents/pypi/bitstring?logo=libraries.io&logoColor=white)](https://libraries.io/pypi/bitstring)\n&nbsp; &nbsp;\n[![Pepy Total Downlods](https://img.shields.io/pepy/dt/bitstring?logo=python&logoColor=white&labelColor=blue&color=blue)](https://www.pepy.tech/projects/bitstring)\n[![PyPI - Downloads](https://img.shields.io/pypi/dm/bitstring?label=%40&labelColor=blue&color=blue)](https://pypistats.org/packages/bitstring)\n\n\nNews\n----\n**April 2024**: bitstring 4.2.1 released.\n \nNew in version 4.2:\n\n* Dropped support for Python 3.7. Minimum version is now 3.8.\n* A new `Dtype` class can be optionally used to specify types.\n* The `bitstring.options` object is now the preferred method for changing module options.\n* New `fromstring` method as another way to create bitstrings from formatted strings.\n* More types can now be pretty printed.\n* A range of 8-bit, 6-bit and even 4-bit floating point formats added (beta):\n* Performance improvements.\n\nSee the [release notes](https://github.com/scott-griffiths/bitstring/blob/main/release_notes.txt) for details. Please let me know if you encounter any problems.\n\n\nOverview\n--------\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\nDocumentation\n-------------\nExtensive documentation for the bitstring module 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\nRelease Notes\n-------------\n\nTo 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.txt).\n\nExamples\n--------\n\n### Installation\n\n    $ pip install bitstring\n\n### Creation\n\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### Different interpretations, slicing and concatenation\n\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\n     BitArray('0x866906690669, 0b000')\n\n### Reading data sequentially\n\n     >>> b = BitStream('0x160120f')\n     >>> b.read(12).hex\n     '160'\n     >>> b.pos = 0\n     >>> b.read('uint12')\n     352\n     >>> b.readlist('uint12, bin3')\n     [288, '111']\n\n### Searching, inserting and deleting\n\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### Arrays of fixed-length formats\n\n     >>> from bitstring import Array\n     >>> a = Array('uint7', [9, 100, 3, 1])\n     >>> a.data\n     BitArray('0x1390181')\n     >>> a[::2] *= 5\n     >>> a\n     Array('uint7', [45, 100, 15, 1])\n\n\n\n<sub>Copyright (c) 2006 - 2024 Scott Griffiths</sub>\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Simple construction, analysis and modification of binary data.",
    "version": "4.2.1",
    "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": "590c5cee1c52f644e7627de467ddc64d5453c395e31ed8d7757a141cf4d12aed",
                "md5": "46f59cdb9b533d04ecd5493979fbbe17",
                "sha256": "9ae5d89072b065d640d645d37c0efcd27284b2f79f1c48cc1cd38b54e1932b4f"
            },
            "downloads": -1,
            "filename": "bitstring-4.2.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "46f59cdb9b533d04ecd5493979fbbe17",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 71861,
            "upload_time": "2024-04-24T19:49:52",
            "upload_time_iso_8601": "2024-04-24T19:49:52.642438Z",
            "url": "https://files.pythonhosted.org/packages/59/0c/5cee1c52f644e7627de467ddc64d5453c395e31ed8d7757a141cf4d12aed/bitstring-4.2.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "eb57699428f6ab4c0863f8555d80ffceb3e7b385622cefdcebe5264121349986",
                "md5": "02f0db0eb095fe013a302e47a5a9e160",
                "sha256": "8abb5a661588c764bacf1a23d64c7bb57517d2841e3e6f54fb8c057119e0540d"
            },
            "downloads": -1,
            "filename": "bitstring-4.2.1.tar.gz",
            "has_sig": false,
            "md5_digest": "02f0db0eb095fe013a302e47a5a9e160",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 249982,
            "upload_time": "2024-04-24T19:49:54",
            "upload_time_iso_8601": "2024-04-24T19:49:54.973859Z",
            "url": "https://files.pythonhosted.org/packages/eb/57/699428f6ab4c0863f8555d80ffceb3e7b385622cefdcebe5264121349986/bitstring-4.2.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-24 19:49:54",
    "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"
}
        
Elapsed time: 0.24470s