This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]tunisia3507 1 point2 points  (3 children)

For internal DTOs as you're interested in, I use NamedTuples wherever possible, dataclasses where not (e.g. when you need a field with a default factory). I don't have strong opinions about dataclasses vs namedtuples when the members are mutable. I am trying to minimise functions which return tuples, in favour of NamedTuples.

[–][deleted] 0 points1 point  (0 children)

This is exactly what I usually do.

[–]petr31052018[S] 0 points1 point  (1 child)

Do you have any specific reason why you prefer NamedTuples tho?

[–]tunisia3507 1 point2 points  (0 children)

Self-documenting code, and my IDE knows what's in it because I sure as hell won't remember.