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

# Sync dependencies
uv sync

# Sync and upgrade dependencies
uv sync --upgrade

# 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.2.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.2-py3-none-any.whl (37.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: tinymsg-0.1.2.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.2.tar.gz
Algorithm Hash digest
SHA256 e6d97256589ce64881eacc43fdf2dbf73d2d61fe53e4104af11055b0a7dc8799
MD5 a6bc8847269de9e1b1e71d5dbffb280a
BLAKE2b-256 75954ced3bed34004315cb10bcb38991e07bd986e5ed92bcfb219dd1f8a787a0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tinymsg-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 37.5 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 2a6fa8f28d258196711e781569b8dd60e6b363a7b8f04eae09a7f322795f22d4
MD5 a2c0c3bde050a368cc37e7052df93624
BLAKE2b-256 67a737ef10230a7befce2a6b7ff8fb631281edff3d098a5157c03391b353c967

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