Skip to main content

Model C structs with Pydantic

Project description

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"

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cmodel-0.3.0.tar.gz (10.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cmodel-0.3.0-py3-none-any.whl (11.1 kB view details)

Uploaded Python 3

File details

Details for the file cmodel-0.3.0.tar.gz.

File metadata

  • Download URL: cmodel-0.3.0.tar.gz
  • Upload date:
  • Size: 10.9 kB
  • Tags: Source
  • Uploaded using 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}

File hashes

Hashes for cmodel-0.3.0.tar.gz
Algorithm Hash digest
SHA256 ca06b66c20811eb0acd391e80b39623968468a5324febbb7b621b460b217651d
MD5 8d626837dcb30c66d90efb7f71b13b7d
BLAKE2b-256 eeed171b33517267922e44edf5918c3bcace6159f4643e7ef9db2f764fbe2f12

See more details on using hashes here.

File details

Details for the file cmodel-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: cmodel-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 11.1 kB
  • Tags: Python 3
  • Uploaded using 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}

File hashes

Hashes for cmodel-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9cb51a4172952c37b8cb1e8cf73ab084a48a0b93677fa823e6c32be424361efa
MD5 5da19fa965cef22b5d841f26c140b715
BLAKE2b-256 c1f66de432e9d84dd46cf68ac9fde5bc5d89d89fd3ace5cae56e474204e52081

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page