You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Dealing with and building named tuples are harder than dealing with dictionaries. So here I propose using dictionaries instead of them. What do you think? Were there some reasons to use named tuples in the first place? If so, why? Let's discuss that.
Edit: Just remembered something, while we can alter and manipulate dictinary throughout the runtime, named tuples are static. This, especially, makes them hard to deal with.
The text was updated successfully, but these errors were encountered:
Dicts and tuples are both fundamental data structures in Python, but very different in purpose, each has its own applications. Dicts have 3-4x larger memory footprint and more expensive to create and access. Hence whenever it's possible, better to opt for tuples. I don't think we can make a general decision about using dicts instead of tuples, instead if you can point to specific cases and argue why tuples mean a large disadvantage there, we could discuss those.
In addition, just to remind of some further advantages of tuples:
Immutability: as you mentioned dicts are mutable, hence poorly designed code can alter them in obscure ways
Hashability: tuples are most often hashable, that means they can be used as dict keys or elements of sets, records can be compared easily and no need to care about duplicates
Dealing with and building named tuples are harder than dealing with dictionaries. So here I propose using dictionaries instead of them. What do you think? Were there some reasons to use named tuples in the first place? If so, why? Let's discuss that.
Edit: Just remembered something, while we can alter and manipulate dictinary throughout the runtime, named tuples are static. This, especially, makes them hard to deal with.
The text was updated successfully, but these errors were encountered: