|
|
|
|
|
by FreakLegion
612 days ago
|
|
TypedDicts "aren't real" in the sense that they're a compile-time feature, so you're getting typing without any deserialization cost beyond the original JSON. Dataclasses and Pydantic models are slow to construct, so that's not nothing. This of course means TypeDicts don't give you run-time validation. For that, and for full-blown custom types in general, I tend to favor msgspec Structs: https://jcristharif.com/msgspec/benchmarks.html#json-seriali.... |
|
Citation needed? Pydantic is really quite fast, and you can pass raw JSON responses into it.
It may be slower (depending on the validators or structure), but I’d expect it to be comparably fast to the stdlib JSON module.