[Python-ideas] Consider adding an iterable option to dataclass

Neil Girdhar mistersheik at gmail.com
Fri Aug 10 19:01:59 EDT 2018


It would be nice if dataclasses 
(https://docs.python.org/3/library/dataclasses.html#dataclasses.dataclass) 
had an option to make them a sequence.  This would make

dataclass(frozen=True, order=True, sequence=True)

an optionally-typed version of namedtuple.  It would almost totally 
supplant it except that namedtuples have a smaller memory footprint.

sequence would simply inherit from collections.abc.Sequence and implement 
the two methods __len__ and __getitme__.

Best,

Neil
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20180810/b2f47822/attachment.html>


More information about the Python-ideas mailing list