Tom Ritchford
1 min readOct 28, 2019

--

Sure you can, and you just did! [Insert smileys to taste.]

Namedtuples have many advantages, as you have pointed out, but two big disadvantages — they are immutable, and they are slow.

The somewhat new dataclass in Python fixes one of these issues, and improves the other. If you can’t use Python 3.7, you can use a backport, or the excellent attrs package which gives you even more functionality.

I love the collections library, so glad to see this article in general. Good stuff!

--

--

No responses yet