Python dicts/lists are not hashable but python objects are. This seems odd to me, particular because python dicts and python objects are nearly identical from a mutability stand point.
I have a couple of theories:
- Two dicts can be equal without having the same
id, and python enforces that equal instances must have the same hash. Objects don't have this behavior by default, but they can if__eq__is overriden - dicts and lists are designed to be mutated. Having them hash to the same value before and after mutating is a foot-gun
What was the design justification for this language feature?
Update from comments: https://docs.python.org/3/glossary.html#term-hashable
This explains why dicts/lists aren't hashable since
Hashable objects which compare equal must have the same hash value.
But why was this rule decided on?