6 ms·
I'm the author of fastcore. dataclasses is not very extensible or flexible. It's fine for starting with, but it's not at all a replacement for store_attr etc.
by jph00 6y ago
I'm the author of fastcore.
dataclasses is not very extensible or flexible. It's fine for starting with, but it's not at all a replacement for store_attr etc.
At fast.ai we used dataclasses extensively for a couple of years, but it just kept biting us. So eventually we switched to these different approaches, which have worked much better for us.
singledispatch is nice enough too, but multiple dispatch with typedispatch is fat more flexible and powerful.
Just because something is in the stdlib, doesn't mean it's the perfect solution to every problem, and that everyone should try to hack their code to fit into those existing solutions.
- nemetroid 6y ago> dataclasses is not very extensible or flexible. It's fine for starting with, but it's not at all a replacement for store_attr etc. > At fast.ai we used dataclasses extensively for a couple of years, but it just kept biting us. What were the issues you had?
- Recursing 6y agohttps://www.attrs.org/en/stable/why.html#data-classes https://www.attrs.org/en/stable/why.html#data-classes The most used python library for these things is attrs, I think it mostly provides support for slotted classes (more memory efficient), "converters" (normalization), validation and serialization
- jph00 6y agoThe key issue is that it requires inheritance, but doesn't actually support subclassing very well. Also it relies on python's type system, which is rather limited. It's a very large module for what it does, and understanding all the details of how it works in practice is a big challenge.