Python Dicts vs NamedTuples
Cluster debates advantages of namedtuples, dataclasses, and classes over dictionaries in Python for lightweight, immutable data structures, focusing on syntax, performance, type safety, and use cases.
Activity Over Time
Top Contributors
Keywords
Sample Comments
Besides immutability, what are the advantages of using namedtuples instead of dicts?
why not use namedtuples (or plain tuples) instead of dictionaries?
Named tuples are fine, but what do they have over using classes or dictionaries?
Yuck. Sorry, but this is worse than dicts or namedtuples in every way.
Dumb question from a non-developer: wouldn't using a dict object make more sense if someone wanted an unordered named tuple?
It lacks the same syntatic sugar as Python dicts :(
What is the advantage of this over using dictionaries?
Switch to namedtuples for lightweight data structures. No regrets.
When you are making str -> Any dictionaries it's quite likely you're better off with dataclasses or namedtuples anyway.
Can you elaborate? What exactly is wrong with dicts?