Remix.run Logo
pletnes 5 days ago

Pydantic seems to be fast (in the context, it’s written in rust) so it might make sense to keep using pydantic for performance reasons.

yedpodtrzitko 5 days ago | parent [-]

Just because it's written in Rust it doesnt mean it's fast. I was working on a project where Pydantic was the bottleneck - there were multiple levels of nested Pydantic objects, and creating the instances was very slow due to the validation which is performed on input values. Even after disablign the validation, dataclasses were twice as fast, compiling the dataclasses with mypyc improved the performance ten times.

ensignavenger 5 days ago | parent [-]

Were you using v2?

Pydantic docs do clearly state that multple levels of nesting of Pydantic objects can make it much slower, so it isn't particularly surprising that such models were slow.