Immutability and Defensive State Design in Python
python typing · by Adrian Benavides · August 6, 2026 · 8 min read
Frozen dataclasses are the default for domain value objects, but they don't validate at runtime. msgspec.Struct closes that gap with a single type that decodes, validates, and stays immutable across the wire boundary and the domain layer. attrs and cattrs cover the same ground in two libraries, and pydantic only earns its place when the ecosystem integration matters.