Apologies if this is the wrong place to ask this question.
I am trying to apply DDD design in my Django apps.
So from there I discover attrs and dataclasses. This article https://www.revsys.com/tidbits/dataclasses-and-attrs-when-and-why/ helped me greatly understand their differences
I stumble upon pydantic so I have tried googling but still none the wiser what pydantic helps to solve that attrs does not.
I think the only one I can find is the typehinting in the IDE. I want to learn so I am posting this question.
Thank you
(I haven't used attrs extensively, so this may be wrong. Anyone with more experience of attrs, feel free to correct me or add to my answer)
The only direct comparison I know is between the attr definition in benchmarks and pydantic definition: pydantic benchmarks model definition vs attr benchmarks model definition.
The problem is that attr lacks many of the validation tools of pydantic, so even for the benchmark we had to use attr + cattr.
Basically attr is much lower level and leaves most validation up to you, it doesn't use or respect type annotations and it lacks many features of pydantic like:
attr is fast though, in some cases even faster than pydantic i think.
Thanks for the reply. I will take some time to go thru this and if I have more questions, will update
The number one feature that is missing, in my opinion, is error path: attrs tells you that you have a validation error, but it does not tell you where. If this data is send to some UI, they won't know which fields to highlight :)
Most helpful comment
(I haven't used attrs extensively, so this may be wrong. Anyone with more experience of attrs, feel free to correct me or add to my answer)
The only direct comparison I know is between the attr definition in benchmarks and pydantic definition: pydantic benchmarks model definition vs attr benchmarks model definition.
The problem is that attr lacks many of the validation tools of pydantic, so even for the benchmark we had to use attr + cattr.
Basically attr is much lower level and leaves most validation up to you, it doesn't use or respect type annotations and it lacks many features of pydantic like:
attr is fast though, in some cases even faster than pydantic i think.