|
|
|
|
|
by martinky24
716 days ago
|
|
Pydantic models are significantly more heavyweight than dataclasses -- They serve as validators as opposed to dataclasses, which are primarily just tools for managing structured data. Both are important problems, but they are different. The power of Pydantic models comes with benefits in terms of what they're able to do out of the box. But this comes at a significant cost of speed, which does matter for some applications. There are plenty of applications where it simply doesn't make sense to validate types every time you stand up a class. Sure you can turn some of that off with Pydantic, etc, etc, but the fact that dataclasses don't require a third party install and are efficient and easy out of the box makes them useful and non-duplicative. |
|