Hacker News new | ask | show | jobs
by botanicalfriend 891 days ago
From my perspective a large factor contributing to its popularity is because of FastAPIs native integration. V2 has broken so much behavior, and the library is generally fragile and slow. Credit where it is due, it is a great library that has done a lot to bring python types to more projects, but there are better solutions out there now.

I’d strongly recommend looking into msgspec. It is a much faster alternative and is largely “correct” in its implementation. It uses all of the python native type annotations without many hacks. Really it is much much faster and can actually be used for performance sensitive python workloads that need strong typing.

1 comments

That's simply not true. It's much faster than most similar libraries, 16x faster than DRF, 30x faster than Cerberus.

Msgspec is impressive in some ways, but there are good reasons to use Pydantic instead - for a start msgspec is written in a non-memory safe language by (mostly) one person, and is less widely tested than Pydantic.