4 ms·
Pydantic is much much much slower than normal dataclasses. However, they have to be because they do validation and dataclasses do not. So, I use normal dataclas
by lysecret 4y ago
Pydantic is much much much slower than normal dataclasses. However, they have to be because they do validation and dataclasses do not. So, I use normal dataclasses for internal constructs, which need to be fast and pydantic for anything that comes externally, can't be trusted and has to be validated.
- stevesimmons 4y agoPydantic models also have a model.construct(*src) form which skips validation. According to Pydantic's docs [1], this makes it 30x faster. [1] https://docs.pydantic.dev/usage/models/#creating-models-without-validation https://docs.pydantic.dev/usage/models/#creating-models-with...