Closed bpiwowar closed 1 year ago
Hey Benjamin! We've got the reasoning for namedtuple
over dataclass
detailed here: https://ir-datasets.com/design.
I understand that NamedTuples are not very conducive to inheritance, but I don't think inheritance adds very much in most cases, and it doesn't seem worth it above the considerations detailed in the link. Can you give some specific case where you'd find inheritance of the fields helpful?
Hi, sorry I did not see this page; OK, this makes sense even though slotted dataclasses should be quite close performance-wise in recent python versions. Maybe to be reconsidered in the future?
I'm potentially open to it!
BTW, in the potential use cases:
isinstance
what to do with one object)Also, a good alternative would be attrs, see e.g. for a full comparison
Is your feature request related to a problem? Please describe. Libraries relying using ir_datasets might need to include extra information into the data objects (e.g. GenericDoc). NamedTuple prevents any inheritence.
Describe the solution you'd like Switch to dataclasses
Describe alternatives you've considered No real alternative apart from trying to use ugly Python constructions or wrappers (but those are not really nice).