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.7.0.tar.gz (14.6 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.7.0-py3-none-any.whl (14.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: cmodel-0.7.0.tar.gz
  • Upload date:
  • Size: 14.6 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.7.0.tar.gz
Algorithm Hash digest
SHA256 1bcb17a4d2e40a48889dd5f7506c919a4a8d0ad899c2b6546a2a2429030d9e44
MD5 28c49182d23ef1d66fcb712820baec9c
BLAKE2b-256 c3d9e9a2f1ea7c9613a5e299c8466a4dcd15ac8354b14b4151b64c8088c7c232

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cmodel-0.7.0-py3-none-any.whl
  • Upload date:
  • Size: 14.8 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.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f1037d01595db9c9bcd2db4aa7bb9971249f9b7625201e0779537be0426d166f
MD5 b2136ec4318e1642921f2067359486f5
BLAKE2b-256 23184e45057d5aca861d00ed12843d38e06d9cf500e404fa94a5f9967bc70261

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