Skip to main content

CModel

PyPI - Version PyPI - Python Version License: MIT

Model C structs with Pydantic

cmodel lets you describe C-compatible binary layouts with normal Pydantic models. You keep Pydantic's validation and nested models, and gain a simple way to pack and unpack structs from binary buffers.

Quick start

from io import BytesIO

from cmodel import CModel
from cmodel.types import Int


class Point(CModel):
	x: Int
	y: Int


buf = BytesIO()
Point(x=3, y=7).c_pack(buf)

buf.seek(0)
point = Point.c_unpack(buf)

assert point == Point(x=3, y=7)
assert buf.getvalue() == b"\x03\x00\x00\x00\x07\x00\x00\x00"

Metadata

Release files for cmodel 0.7.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cmodel 0.7.0
File Size Uploaded
cmodel-0.7.0.tar.gz 14.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for cmodel 0.7.0
File Interpreter ABI Platform
cmodel-0.7.0-py3-none-any.whl Python 3 none any Details

Total release size: 29.4 kB

Release files / cmodel-0.7.0.tar.gz

Download URL cmodel-0.7.0.tar.gz
Size 14.6 kB
Tags Source
SHA-256 checksum
How to use checksums
1bcb17a4d2e40a48889dd5f7506c919a4a8d0ad899c2b6546a2a2429030d9e44
BLAKE2b-256 checksum
How to use checksums
c3d9e9a2f1ea7c9613a5e299c8466a4dcd15ac8354b14b4151b64c8088c7c232
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.10.0 {"installer":{"name":"uv","version":"0.10.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / cmodel-0.7.0-py3-none-any.whl

Download URL cmodel-0.7.0-py3-none-any.whl
Size 14.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f1037d01595db9c9bcd2db4aa7bb9971249f9b7625201e0779537be0426d166f
BLAKE2b-256 checksum
How to use checksums
23184e45057d5aca861d00ed12843d38e06d9cf500e404fa94a5f9967bc70261
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.10.0 {"installer":{"name":"uv","version":"0.10.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

This release

0.7.0 This release

2 release files

0.6.0

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page