Comment

Comment by ReflectedImage

Because namedtuple is a simpler construct than frozen dataclass therefore it is always preferable in Python.

The number of characters and lines to access the members of namedtuple is significantly less than dataclass.

dataclass would have similar issues if st_dev was now defined as a string whereas namedtuple would not.

Whilst there maybe edge cases in using simpler constructs, in scripting languages we accept the edge cases as it pays off in 99.99% of cases to simply ignore them. If something goes wrong, you catch the exception "Ask for forgiveness not for permission" if you want to look up the concept.

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton