$npx skillfedfor your agent

bitstruct

This module performs conversions between Python values and C bit field structs represented as Python byte strings.

With conditionsPyPI Software DevelopmentReleased Feb 20265.1M downloads / moMITPlatform wheel

Decision gist · record as of 2026-08-14

platform wheels — bitstruct-8.22.1-cp310-cp310-macosx_10_9_x86_64.whl · bitstruct-8.22.1-cp310-cp310-macosx_11_0_arm64.whl · bitstruct-8.22.1-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
v8.22.1 · released 2026-02-17 · Python >=3.9

Yes, if you need to work with bit-level binary data. Bitstruct is stable (Production/Stable status), actively maintained, has no dependencies, and provides a clear interface for a specialized but real problem. The optional C acceleration and wide platform support make it practical for both development and performance-critical code. No security vulnerabilities reported.AI-flagged interpretation of the facts on this page — verify before relying

Before you install

  • Requires Python 3.9 or later.
  • C implementation available only on CPython 3 and must be explicitly imported; pure Python fallback is default.
  • Medium install friction due to compiled C extensions for multiple platforms (wheels provided for CPython 3.10–3.11 across Linux, macOS, Windows, and ARM architectures).

License · maintenance · safety

MIT (permissive) — MIT license permits unrestricted use, modification, and distribution in both open and closed-source projects with minimal attribution requirements.

last release 2026-02-17 (178 days) · last repo commit 2026-02-17 · 135 stars

0 known vulnerabilities (OSV.dev, 2026-08-14) · 5,110,055 downloads/mo, #2,167 on PyPI

Verify before relying

pip install bitstruct

from bitstruct import pack, unpack
packed = pack('u1u3u4s16', 1, 2, 3, -4)
print(packed)  # b'\xa3\xff\xfc'
unpacked = unpack('u1u3u4s16', packed)
print(unpacked)  # (1, 2, 3, -4)
  • Whether the C implementation is automatically selected or requires explicit import on supported platforms
  • Performance characteristics and speedup magnitude of C vs. pure Python implementation for typical workloads
  • Compatibility with Python 3.12+ beyond the stated 3.9+ requirement
Same gist for agents: .md · .json

What it is and what it does

Bitstruct converts between Python values and bit-level binary structures, extending the interface of Python's built-in struct module to work on individual bits instead of bytes. It provides functions to pack values into compact binary representations and unpack them back, with support for unsigned integers, signed integers, floats, booleans, raw bytes, and text strings at arbitrary bit boundaries.

Format strings specify bit widths and types (e.g., 'u1u3u4s16' for a 1-bit unsigned, 3-bit unsigned, 4-bit unsigned, and 16-bit signed integer), and compiled format objects allow reuse of the same specification across multiple operations. It supports bit-offset packing into existing buffers, dictionary-based packing/unpacking, and byte-order control. The library includes both a pure Python implementation and optional C accelerations for faster pack/unpack operations on CPython 3.

Use it for

  • Parse binary network protocols or file formats with non-byte-aligned fields (e.g., bit flags, variable-width integers)
  • Serialize structured data into compact binary representations for embedded systems or bandwidth-constrained communication
  • Extract and manipulate individual bit fields from hardware register dumps or low-level binary data
  • Implement bit-level codecs for compression or encoding schemes that operate below byte boundaries
  • Test and validate binary protocol implementations by packing/unpacking known test vectors

Worth the install?

AI-flagged interpretation of the facts on this page. Verify before relying on it.

With conditions

Yes, if you need to work with bit-level binary data.

Bitstruct is stable (Production/Stable status), actively maintained, has no dependencies, and provides a clear interface for a specialized but real problem. The optional C acceleration and wide platform support make it practical for both development and performance-critical code. No security vulnerabilities reported.

Install

bitstruct on PyPI

Before you install

Medium install friction due to compiled C extensions for multiple platforms (wheels provided for CPython 3.10–3.11 across Linux, macOS, Windows, and ARM architectures). Active maintenance with recent releases; no runtime dependencies.

Requires Python 3.9 or later. C implementation available only on CPython 3 and must be explicitly imported; pure Python fallback is default.

License in practice

MIT license permits unrestricted use, modification, and distribution in both open and closed-source projects with minimal attribution requirements.

Quickstart

pip install bitstruct

from bitstruct import pack, unpack
packed = pack('u1u3u4s16', 1, 2, 3, -4)
print(packed)  # b'\xa3\xff\xfc'
unpacked = unpack('u1u3u4s16', packed)
print(unpacked)  # (1, 2, 3, -4)

Verify before relying

  • Whether the C implementation is automatically selected or requires explicit import on supported platforms
  • Performance characteristics and speedup magnitude of C vs. pure Python implementation for typical workloads
  • Compatibility with Python 3.12+ beyond the stated 3.9+ requirement

Package facts

LicenseMIT permissive
Python supportSupports the current Python release >=3.9
Install frictionMedium. Platform-specific wheel
Runtime dependenciesNone
MaintenanceActively maintained 178 days since the last release
Last repo commit
First released
Downloads5,110,055 / month, #2,167 on PyPI 30-day window, as of 2026-08-14
Known vulnerabilitiesNone known OSV.dev, checked 2026-08-14
Classifiers
Development Status :: 5 - Production/StableProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: Implementation :: CPython

Evidence: bitstruct-8.22.1-cp310-cp310-macosx_10_9_x86_64.whl; bitstruct-8.22.1-cp310-cp310-macosx_11_0_arm64.whl; bitstruct-8.22.1-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl; bitstruct-8.22.1-cp310-cp310-manylinux2014_armv7l.manylinux_2_17_armv7l.manylinux_2_31_armv7l.whl; bitstruct-8.22.1-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl; bitstruct-8.22.1-cp310-cp310-musllinux_1_2_aarch64.whl; bitstruct-8.22.1-cp310-cp310-musllinux_1_2_armv7l.whl; bitstruct-8.22.1-cp310-cp310-musllinux_1_2_x86_64.whl; bitstruct-8.22.1-cp310-cp310-win32.whl; bitstruct-8.22.1-cp310-cp310-win_amd64.whl; bitstruct-8.22.1-cp310-cp310-win_arm64.whl; bitstruct-8.22.1-cp311-cp311-macosx_10_9_x86_64.whl; bitstruct-8.22.1-cp311-cp311-macosx_11_0_arm64.whl; bitstruct-8.22.1-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl; bitstruct-8.22.1-cp311-cp311-manylinux2014_armv7l.manylinux_2_17_armv7l.manylinux_2_31_armv7l.whl; bitstruct-8.22.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl; bitstruct-8.22.1-cp311-cp311-musllinux_1_2_aarch64.whl; bitstruct-8.22.1-cp311-cp311-musllinux_1_2_armv7l.whl; bitstruct-8.22.1-cp311-cp311-musllinux_1_2_x86_64.whl; bitstruct-8.22.1-cp311-cp311-win32.whl

Tags

Capabilities
bit packing unpackingbinary bit field parsingstruct module bitsbit-level serializationbinary protocol parsingbit manipulationcompact binary encoding
Topics
binary-serializationbit-manipulationprotocol-parsing
PyPI keywords
bit fieldbit parsingbit unpackbit pack

Let your AI agent find packages like this

Example. Real query, live index.

You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.

wish › “bit packing unpacking”

  • bitstructPacks and unpacks Python values into bit-level binary structures,…
  • cbitstructA C-accelerated implementation of the bitstruct library that packs…
  • bitstringbitstring provides Python classes and functions to create,…

Give your agent the search over MCP, or paste the wish link into any chat.

More Software Development packages

typing-extensions Worth it
PyPI · Software Development · released Jul 2026

Provides backported and experimental type hints for Python 3.9+, allowing use of newer typing features on older Python versions and enabling early experimentation with type system PEPs before they enter the standard library.

PSF-2.0pure Python · 3.9+
1.9Bdownloads / mo
numpy Worth it
PyPI · Software Development · released Aug 2026

NumPy provides an N-dimensional array object and a comprehensive suite of mathematical, linear algebra, Fourier transform, and random number functions for scientific computing in Python.

BSD-3-Clause AND 0BSD AND MIT AND Zlib AND CC0-1.0compiled wheel · 3.12+
1.1Bdownloads / mo
fastapi Worth it
PyPI · Software Development · released Jul 2026

FastAPI is a Python web framework for building REST APIs using type hints, with automatic request validation, serialization, and interactive API documentation.

MITpure Python · 3.10+
568.6Mdownloads / mo
annotated-doc With conditions
PyPI · Software Development · released Jul 2026

Provides a way to document function parameters, class attributes, return types, and variables inline using Python's `Annotated` type hint syntax instead of traditional docstrings.

MITpure Python · 3.9+
456.2Mdownloads / mo
typer Worth it
PyPI · Software Development · released Aug 2026

Typer builds command-line applications from Python functions using type hints, automatically generating help text, argument parsing, and shell completion.

Install it if you are building CLIs in Python.

MITpure Python · 3.10+
369.3Mdownloads / mo
distlib With conditions
PyPI · Software Development · released Jun 2026

Distlib provides low-level packaging utilities for building, distributing, and managing Python software—including metadata handling, version specifiers, wheel support, script installation, and dependency resolution.

permissive licensepure Python
323.3Mdownloads / mo

See also bitstring · cbitstruct · plum-py · dissect.cstruct · kaitaistruct · tibs · construct-classes · msgpack · bitarray-hardbyte · fdt