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.6.0.tar.gz (11.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.6.0-py3-none-any.whl (12.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: cmodel-0.6.0.tar.gz
  • Upload date:
  • Size: 11.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.6.0.tar.gz
Algorithm Hash digest
SHA256 c78f8212877ef08d646c4b69017131b8247dff0c0380c9ee47b34a8c3f82db0a
MD5 6646b51b72599fe6aa24886b9900d62f
BLAKE2b-256 1196dfc8df9dcb33cb48c676235646db369fc063f4f9214ce88ee9798059594c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cmodel-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 12.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.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e39eb2775e02c3b0cc5c12296b2b8fb37e8f9559afaf49d0d61803d27262c6f8
MD5 a1768e4fe104126968466e718cc5ea70
BLAKE2b-256 48478e7c5162a3058478e202a69615702bbae0190ad701ad77dcb300b2c4eb14

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