4 ms·
Hashmaps are often overrated. I can count on my fingers how many times I used dictionaries in Python. Pretty much anything you can do with dictionaries can be m
by wheelerof4te 5y ago
Hashmaps are often overrated. I can count on my fingers how many times I used dictionaries in Python. Pretty much anything you can do with dictionaries can be much more cleanly done with classes and other built-in features.
Membership testing? Use sets. Data storage? Use classes with slots or tuples/namedtuples. Custom switch statement? Use the new match/case keywords or just fall back to plain if/elif towers.
It's so much simpler.
- dzaima 5y agoIt definitely depends on the project. There are plenty of domains where hashmaps are useless, and some where half the things you do need one, and many in between. The in-between is the worst - if you need a hashset/hashmap just once, you'd still have to suffer through implementing one (O(n^2) is just not acceptable). But there is a bright side to this - hashmaps are pretty inefficient if a list could do, so the more you're pushed against using one, the more likely you are to have faster code :) (as long as you don't go the O(n^2) route, that is; also, hashsets are equally hard to implement manually as hashmaps)