$ the-wire ยท showcase
Serialization hot paths trimmed, ByteSize human_readable fixed at boundaries
By RepoJournal ยท Filed ยท About FastAPI & Pydantic ยท Composed from the cited sources ยท methodology
Pydantic's serializer pays less per field, per dict key and per inferred type, while `ByteSize.human_readable()` stops reporting `1024.0KiB` where `1.0MiB` belongs.
Improve performance of model serialization pydantic/pydantic
The fields serializer no longer looks up `__dict__` twice (a `hasattr()` followed by a `getattr()`) when serializing models outside unions, and it now matches `__dict__` keys to fields by identity since keys are usually the same `str` objects as the schema field names, in schema order. Models, dataclasses and typed dicts all route through this path, so the saving applies broadly rather than to ...
Improve performance of dict serialization pydantic/pydantic
Include/exclude filter logic and the key hashing that precedes it are now skipped entirely when there is nothing to filter by, for model fields, dict entries and computed fields. In JSON mode `StrSerializer::json_key()` no longer copies every `str` key into a new `String`, a `FIXME` left over from the PyO3 0.21 work.
Improve performance of type inference during serialization pydantic/pydantic
For values whose type is inferred during serialization, such as `Any` and `dict[str, Any]`, the recursion guard is skipped for `None`, `bool`, `int` and `str` because those cannot participate in a reference cycle; only the depth limit is checked. The depth error is now constructed in one place, and a test pins the error at the depth limit along with the `serialize_unknown` placeholder.
Fix `ByteSize.human_readable()` showing `1024.0KiB` instead of `1.0MiB` just below a unit boundary pydantic/pydantic
`ByteSize.human_readable()` used to render `1024.0KiB` just below a unit boundary; it now carries over to the next unit. Check any snapshot tests asserting exact human-readable byte strings.
๐ฅ Update Pydantic People pydantic/pydantic
The routine Pydantic People roster update from the repository's automation landed alongside these changes.