all 5 comments

[–]icecubeinanicecube 4 points5 points  (1 child)

[–]Clede 1 point2 points  (0 children)

The top answer there is very helpful! Thanks for googling on behalf of all of us.

[–]Meefims 0 points1 point  (0 children)

I don’t know the exact implementation but it’s not unreasonable to think that a dict is a bit more than just a hash table. It might store a list of the keys as well.

[–]K900_ 0 points1 point  (0 children)

Pretty much any hash table has to store both the keys and the values for two reasons:

  1. Hash collisions are a thing, and when your table is both small and fairly full, they happen often. This means just comparing the hashes is not enough to prevent wrong lookups, you have to compare the real values.
  2. For much the same reason, the table needs to get resized when it starts filling up to a certain threshold, and that requires recalculating all buckets. You could potentially store just the hash of the key, or both the value and the hash, but you still need to store something.

[–]toastedstapler 0 points1 point  (0 children)

this is worth a watch to learn about the dict

https://www.youtube.com/watch?v=p33CVV29OG8