Skip to main content

A lightweight serialization library for Python using MessagePack with type-safe Pydantic models

Project description

tinymsg

A lightweight serialization library for Python using MessagePack with type-safe Pydantic models. This Python instance of the tinymsg serialization library is directly compatible with tinymsg-cpp and tinymsg-rs (coming soon).

Features

  • Type-safe: Built on Pydantic for automatic validation and type checking
  • Fast: Uses MessagePack for efficient binary serialization
  • Simple: Minimal boilerplate - just inherit from Message
  • Nested support: Handles nested objects, lists, and dicts automatically

Installation

uv add tinymsg       # using uv
pip install tinymsg  # using pip

Quick Start

from tinymsg import Message

class Person(Message):
    name: str
    age: int
    email: str

class Team(Message):
    name: str
    members: list[Person]
    active: bool = True

# Create objects
alice = Person(name="Alice", age=30, email="alice@example.com")
bob = Person(name="Bob", age=25, email="bob@example.com")
team = Team(
    name="Engineering", 
    members=[alice, bob]
)

# Serialize to bytes
data = team.pack()

# Deserialize from bytes
restored_team = Team.unpack(data)

print(restored_team.members[0].name)  # "Alice"

Development

This project uses uv, a fast Python package and project manager. Install it first:

curl -LsSf https://astral.sh/uv/install.sh | sh

Setup Development Environment

Automatically create the virtual environment and sync all the dependencies (including dev dependencies):

uv sync --group dev

Install the pre-commit hooks to auto-run linting, formatting, and static type checks:

uv run pre-commit install

Development Commands

# Run tests
uv run pytest
uv run pytest --cov=tinymsg --cov-report=html

# Lint and format code with ruff (runs automatically with pre-commit)
uv run ruff check .
uv run ruff check --fix .
uv run ruff format .

# Type checking (runs automatically with pre-commit)
uv run mypy .

# Run all pre-commit hooks manually (includes ruff, mypy, and uv-lock)
uv run pre-commit run --all-files

Other Useful Commands

# Add a new dependency
uv add requests

# Add a new dev dependency
uv add --dev mypy

# Update dependencies
uv sync

# Show dependencies
uv tree

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

tinymsg-0.1.1.tar.gz (32.6 kB view details)

Uploaded Source

Built Distribution

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

tinymsg-0.1.1-py3-none-any.whl (37.3 kB view details)

Uploaded Python 3

File details

Details for the file tinymsg-0.1.1.tar.gz.

File metadata

  • Download URL: tinymsg-0.1.1.tar.gz
  • Upload date:
  • Size: 32.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.4

File hashes

Hashes for tinymsg-0.1.1.tar.gz
Algorithm Hash digest
SHA256 a1b7de894842ee5890d0a89b840dc1045cd4a6ca85a73d9a1812fed945cf8d67
MD5 0450afb173ae48dcff9558f06e21c720
BLAKE2b-256 12ed97367ef65b8dea750e02a4ba6fdb8d8f1ab0e0236395fa03aaf08349a9d5

See more details on using hashes here.

File details

Details for the file tinymsg-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: tinymsg-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 37.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.4

File hashes

Hashes for tinymsg-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 81398cca464afc4cf7408420746a9c5891ef05b0e7466fcf717e6bfcbded23cb
MD5 213a92895371fba018e0d1155d01b551
BLAKE2b-256 d70cdad49c5c5418d34e60aa35eb0412be3ba7ef6db5c09d04936039f696c8f2

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