by kortex · 4y ago · 0 comments
Pydantic requires inheritance and requires a modified mypy because it uses types its own way rather than the python way.
Oh, typedload is faster than pydantic, despite being pure python instead of an .so file.
I'm pretty sure that serde, the rust library that Pydantic uses, is faster than the JSON parser written in C in the python standard lib, so I'd be very surprised if your pure python validation library beat pydantic.
At the bottom there are instructions on how to run the benchmark locally.
So I modified the benchmarking code to include loading JSON[0], and your library still came out on top!
But, it turns out I was wrong about pydantic using serde under the hood. Pydantic version 2 will. And the maintainer aims for it to be about 10x faster [1] than version 1.
Nonetheless, this was definitely a surprise for me, and if I ever go back to using Python, I'll definitely check your library out!
I'm curious, why do you think pydantic took off and your library didn't? It looks like your library is both faster and easier to use to me.
[0] https://github.com/davidatsurge/typedload/pull/1/files?diff=...