pycstruct
Binary data handling in Python using dictionaries
What it is and what it does
pycstruct is a Python library for bidirectional conversion between binary data and Python dictionaries or objects. It lets you define binary layouts using a C-struct-like syntax—specifying fields with types like uint32, float32, bool8, and arrays—then serialize Python data into binary form or deserialize binary files back into Python objects. The library handles complex nested structures, unions, bitfields, and enums, with full control over byte order and field alignment.
Typical use cases are reading and writing binary file formats or parsing binary protocols transmitted over networks. The package also includes a C source code parser that can automatically generate pycstruct definitions from existing C struct declarations, eliminating manual definition work when you already have C headers.
Use it for:
- Parse binary file formats (e.g., image headers, audio metadata) by defining the layout once and deserializing file contents into dictionaries
- Serialize Python objects into binary protocol messages for network transmission with precise byte-order and alignment control
- Automatically generate pycstruct definitions from C source code to avoid manual transcription of struct layouts
- Handle embedded C structs, unions, and bitfields in Python without writing custom pack/unpack logic
- Read and write binary data with variable-length arrays and nested structures at any nesting depth
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Converts binary data to and from Python dictionaries or objects using C-struct-like definitions, supporting structs, unions, bitfields, enums, and arrays with configurable byte order and alignment.
Yes, if you need to work with binary data or C-compatible struct layouts. The package is stable, has no dependencies, and carries permissive MIT licensing. However, dormant maintenance (873 days since last release) means you should verify it handles your specific use case before committing to it in production—no active support or bug fixes should be expected.
Install
pycstruct on PyPI
pip
pip install pycstructuv
uv add pycstructpoetry
poetry add pycstructInstalling pycstruct
Before you install
Low install friction with no runtime dependencies. Dormant maintenance status—last release was 873 days ago, though the repository remains active with a recent commit on 2024-03-24.
License in practice
MIT license permits commercial and private use with minimal restrictions, requiring only attribution and inclusion of the license notice.
Quickstart
import pycstruct
person = pycstruct.StructDef()
person.add('utf-8', 'name', length=50)
person.add('uint32', 'age')
person.add('float32', 'height')
with open('data.bin', 'rb') as f:
result = person.deserialize(f.read())
Verify before relying
- Whether the package is actively maintained or if dormant status signals abandonment risk
- Compatibility with Python versions beyond 3.11 (classifiers list 3.4–3.11 but no explicit upper bound)
Package facts
| License | MIT (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | dormant — 873 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 164,380/month — #10,549 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: pycstruct-0.12.2-py3-none-any.whl
Keywords: struct, enum, bitfield, binary, protocol, dict, dictionary
Tags
More Build Tools packages
Provides reusable utilities for Python…
permissive · top 100 on PyPI
tqdmWraps any iterable to display a real-time…
copyleft · top 100 on PyPI
pippip is the standard installer for Python…
permissive · top 100 on PyPI
hatchlingHatchling is a standards-compliant Python build…
permissive · top 100 on PyPI
grpcio-toolsGenerates Python gRPC service stubs and message…
permissive · top 1,000 on PyPI
pre-commitpre-commit is a framework for installing and…
permissive · top 1,000 on PyPI
dissect.cstructParse binary data using C-like structure…
permissive · top 15,000 on PyPI
poly-eip712-structsConstructs and serializes EIP-712 structured…
permissive · top 5,000 on PyPI
construct-classesParses binary data into Python dataclasses and…
permissive · top 15,000 on PyPI
cbitstructA C-accelerated implementation of the bitstruct…
copyleft · top 15,000 on PyPI
constructConstruct is a declarative parser and builder…
permissive · top 5,000 on PyPI
plum-pyTransforms byte sequences into Python objects…
permissive · top 15,000 on PyPI
pyclibraryParses C header files and automates…
permissive · top 15,000 on PyPI
cobsEncodes and decodes data using Consistent…
permissive · top 15,000 on PyPI
bitstructPacks and unpacks Python values into bit-level…
permissive · top 5,000 on PyPI
http-sfParses and serializes HTTP Structured Fields as…
permissive · top 15,000 on PyPI