On Thu, Jul 29, 2021 at 9:07 AM <pavel@lexyr.com> wrote:
[Migrating the discussion from https://bugs.python.org/issue44768.]
PEP 20 says:
There should be one-- and preferably only one --obvious way to do it.
There are two ways to create a simple named type to store data: collections.namedtuple and dataclasses.dataclass. I propose deprecating namedtuple.
As far as the interface is concerned, the namedtuple is almost completely equivalent to a frozen dataclass - with some iterability syntactic sugar thrown in. I don't think there are use cases for namedtuple that would not be trivial to rewrite with dataclasses.
A namedtuple is fundamentally a tuple. A dataclass isn't. There are times when each one should be used. What's the justification for removing one of them? ChrisA