Ben Avrahami <avrahami....@gmail.com> wrote 9 Feb 2021, 03:30:

> That's the current alternative, but namedtuples (unlike dataclasses) are 
> slotted, which makes them more space-efficient and (slightly) faster.

When I use @dataclass(frozen=True), I manually add a __slots__ attribute. I 
presume this makes the resulting objects similar in size to NamedTuples, but I 
haven't done any measurements (and not sure how to measure this anyway).

I wonder: is it possible for @dataclass to have an option slots=True? 
And perhaps frozen=True should imply slots=True (would this cause any backwards 
compatibility problems?).
_______________________________________________
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/OBFNLB363DQM5YELR46M3OI3BNKIKSPB/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to