Dataclasses are available without adding a dependency, but that's their only advantage. That's no small thing when it means the standard library can use them, but most other situations should use attrs.
attrs moves faster than could be accommodated if it were moved in to the standard library.
attrs supports additional features not being proposed here: validators, converters, metadata, etc. Data Classes makes a tradeoff to achieve simplicity by not implementing these features.
Every aspect of the design here appears to be converging further in the direction of exact duplication of functionality available within attrs, except those which are features already on attrs's roadmap.
An important bit here is hynek's opinion on the subject: he'd find both importing-and-freezing (à la ipaddress) and importing-and-splitting (json/simplejson) undesirable, leaving only "versioned and upgradable", but while that's easy for a command-line utility (pip) it's quite a bit harder for a part of the standard library.
I feel like we're trending towards another "/r/python hates everything" thread- and like I've contributed to that - so let's derail that now.
If you are asking "should I use dataclasses or attrs", the answer is always attrs.
BUT very many people are not in that position, and dataclasses will be a big improvement for many of them.
I strongly recomend that everyone in this thread go read Nick Coghlan's essay Considering Python's Target Audience - tldr, it's much bigger and more diverse than most of us imagine!
9
u/PeridexisErrant May 16 '18
Yes, it's basically reinventing
attrsbadly.Dataclasses are available without adding a dependency, but that's their only advantage. That's no small thing when it means the standard library can use them, but most other situations should use
attrs.