pypackd
Unified Python serializer with msgspec MessagePack backend. One API for all your types — Pydantic, msgspec Structs, dataclasses, and every stdlib type.
Installation
pip install pypackd
With Pydantic support:
pip install pypackd[pydantic]
Usage
from serializer import Serializer
# Serialize any supported type
data = Serializer.serialize(my_object)
# Deserialize with target type
obj = Serializer.deserialize(data, MyType)
Primitives & Collections
Serializer.deserialize(Serializer.serialize(42), int) # 42
Serializer.deserialize(Serializer.serialize("hello"), str) # "hello"
Serializer.deserialize(Serializer.serialize([1, 2, 3]), list) # [1, 2, 3]
Serializer.deserialize(Serializer.serialize({10, 20}), set) # {10, 20}
Dataclasses
from dataclasses import dataclass
@dataclass
class Point:
x: float
y: float
p = Point(3.14, 2.72)
data = Serializer.serialize(p)
Serializer.deserialize(data, Point) # Point(x=3.14, y=2.72)
msgspec Structs
import msgspec
class Config(msgspec.Struct):
host: str
port: int
debug: bool = False
cfg = Config(host="localhost", port=8080)
data = Serializer.serialize(cfg)
Serializer.deserialize(data, Config) # Config(host='localhost', port=8080, debug=False)
Pydantic Models
from pydantic import BaseModel
from datetime import datetime
from uuid import UUID
class User(BaseModel):
id: UUID
name: str
created_at: datetime
user = User(id=UUID("abcdef01-2345-6789-abcd-ef0123456789"), name="Georg", created_at=datetime.now())
data = Serializer.serialize(user)
Serializer.deserialize(data, User) # User(id=UUID('abcdef01-...'), name='Georg', ...)
Nested Types
Pydantic models with dataclass fields, nested Pydantic models, or any combination — it just works.
@dataclass
class Address:
street: str
city: str
class Order(BaseModel):
order_id: int
customer: User
shipping: Address
items: list[str]
order = Order(order_id=1, customer=user, shipping=Address("Hauptstr. 1", "Berlin"), items=["Laptop"])
data = Serializer.serialize(order)
Serializer.deserialize(data, Order) # Full roundtrip with all nested types
Supported Types
| Category | Types |
|---|---|
| Primitives | str, int, float, bool, None, bytes |
| Collections | list, dict, tuple, set, frozenset |
| Datetime | datetime, date, time, timedelta |
| Stdlib | UUID, Decimal, Enum |
| Structured | dataclass, NamedTuple, TypedDict, msgspec.Struct |
| Pydantic | BaseModel, RootModel (incl. computed fields, aliases, excluded fields, custom serializers, model/field validators) |
| Typing | Optional, Union, Literal, generics |
How It Works
pypackd is a thin adapter layer over msgspec, which handles all non-Pydantic types natively with zero overhead. For Pydantic models, pypackd auto-detects the model's features and chooses the fastest serialization path:
- Simple models →
obj.__dict__(2-5x faster thanmodel_dump()) - RootModel, models with computed fields, aliases, excluded fields, or custom serializers →
model_dump(mode='python')for correctness
Type classifications are cached, Encoder/Decoder instances are reused, and all cache writes are thread-safe. 292 tests, 99% code coverage.
Error Handling
All errors are wrapped in a unified exception hierarchy:
from serializer import SerializerError, SerializeError, DeserializeError
try:
Serializer.deserialize(data, MyModel)
except DeserializeError as e:
print(e) # Descriptive message
print(e.__cause__) # Original pydantic/msgspec exception
Requirements
- Python 3.10+
- msgspec >= 0.18
- pydantic >= 2.0 (optional)
License
MIT
Metadata
Release files for pypackd 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pypackd-0.1.1.tar.gz | 20.8 kB | With provenance | Details for pypackd-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pypackd-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for pypackd-0.1.1-py3-none-any.whl |
Total release size: 28.1 kB
Release files / pypackd-0.1.1.tar.gz
| Download URL | pypackd-0.1.1.tar.gz |
|---|---|
| Size | 20.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6a67df395f755c103214b267e5eb4ad43e85535b04a622d6af5e08bb92a514b1
|
|
BLAKE2b-256 checksum How to use checksums |
d4afff48c2c19dc055b61774ade55aa57d56ddb1f25bf46de376398e29d513c3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 14, 2026.
Transparency logRelease files / pypackd-0.1.1-py3-none-any.whl
| Download URL | pypackd-0.1.1-py3-none-any.whl |
|---|---|
| Size | 7.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1b31f8eea7b5ac28dad069279574bd931f477d2744c9bedc3ef4b06abb843855
|
|
BLAKE2b-256 checksum How to use checksums |
f9961016e0d4a6abd8d373b13020501b3e2dde5b09014efb9e7ca56c81932f90
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 14, 2026.
Transparency logSecurity for pypackd 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for pypackd-0.1.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 14, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.