attrs (predecessor of the builtin dataclasses module), is a library that helps create data transfer objects. It has a section of why you should prefer it over namedtuples. I think it is well worth reading.
(However, they do not mention that named tuples are much faster to instantiate than attrs classes, because they run no validations and are implemented in C)
Yes. As mentioned on attrs docs, Namedtuples have some limitations over attrs. But for the simple use, where you just have to give names to your fields and want a faster solution, I think Namedtuples are the way to go.
Namedtuples are ultimately just Tuples, they are not supposed to be used as some replacement for classes.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
attrs
(predecessor of the builtindataclasses
module), is a library that helps create data transfer objects. It has a section of why you should prefer it overnamedtuples
. I think it is well worth reading.(However, they do not mention that named tuples are much faster to instantiate than
attrs
classes, because they run no validations and are implemented in C)Yes. As mentioned on
attrs
docs,Namedtuples
have some limitations overattrs
. But for the simple use, where you just have to give names to your fields and want a faster solution, I think Namedtuples are the way to go.Namedtuples are ultimately just
Tuples
, they are not supposed to be used as some replacement for classes.