Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dictionaries as a standard #205

Open
MelihDarcanxyz opened this issue Nov 21, 2022 · 1 comment
Open

Dictionaries as a standard #205

MelihDarcanxyz opened this issue Nov 21, 2022 · 1 comment
Labels
suggestion Suggestion and ideas for development

Comments

@MelihDarcanxyz
Copy link
Contributor

MelihDarcanxyz commented Nov 21, 2022

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.

@MelihDarcanxyz MelihDarcanxyz added the bug Problem in the code label Nov 21, 2022
@ervau ervau added the suggestion Suggestion and ideas for development label Nov 26, 2022
@deeenes
Copy link
Member

deeenes commented Nov 30, 2022

Hello,

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

@deeenes deeenes removed the bug Problem in the code label Nov 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
suggestion Suggestion and ideas for development
Projects
None yet
Development

No branches or pull requests

3 participants