But heterogeneous iteration would require typing changes

On Thu, 29 Jul 2021, 02:18 Eric V. Smith, <e...@trueblade.com> wrote:

> In dataclasses, support for __slots__ is being added in 3.10. Adding
> optional support for iteration would be easy.
>
> --
> Eric V. Smith
>
> On Jul 28, 2021, at 7:29 PM, Paul Bryan <pbr...@anode.ca> wrote:
>
> 
> I'm with you; since dataclasses were introduced, namedtuple has not see
> any use from me, though none of my uses have demanded ultra-high efficiency
> either.
>
> I wonder how many users are currently relying on namedtuple __getitem__
> semantics though. that's functionality dataclasses do not (currently) have.
>
> Random thought I don't know the answer to: Any reason __slots__ can't be
> used on a dataclass to improve efficiency?
>
>
> On Wed, 2021-07-28 at 22:22 +0000, pa...@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.
>
> As far as the implementation is concerned, the namedtuple is faster. If
> efficiency is a concern, why do we make our users decide? We can choose the
> most efficient one on the library's end. C++ does something similar with
> bool vectors - the library has a special case for where it would be more
> optimal to use a different data structure underneath.
>
>
> TL;DR: If dataclass is so good, why keep namedtuple around?
> _______________________________________________
> Python-ideas mailing list -- python-ideas@python.org
> To unsubscribe send an email to python-ideas-le...@python.org
> https://mail.python.org/mailman3/lists/python-ideas.python.org/
> Message archived at
> https://mail.python.org/archives/list/python-ideas@python.org/message/UQRCDWMFNC5NRLLQCTYPOEGWJOIV7BGJ/
> Code of Conduct: http://python.org/psf/codeofconduct/
>
>
> _______________________________________________
> Python-ideas mailing list -- python-ideas@python.org
> To unsubscribe send an email to python-ideas-le...@python.org
> https://mail.python.org/mailman3/lists/python-ideas.python.org/
> Message archived at
> https://mail.python.org/archives/list/python-ideas@python.org/message/4NOUPTLNNJJMM3XSN3WEK32NWRJDAVRD/
> Code of Conduct: http://python.org/psf/codeofconduct/
>
> _______________________________________________
> Python-ideas mailing list -- python-ideas@python.org
> To unsubscribe send an email to python-ideas-le...@python.org
> https://mail.python.org/mailman3/lists/python-ideas.python.org/
> Message archived at
> https://mail.python.org/archives/list/python-ideas@python.org/message/ESOIUHFM26SPCLP4VZCY7WETXJWFVBOC/
> Code of Conduct: http://python.org/psf/codeofconduct/
>
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/XXG2WNIZRDHXCLJHDAAHME5CKJV7ZMVF/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to