In general it is more useful and intuitive to have equality based on value and not identity. For example, consider the following snippet:
from collections import Counter
words = 'dog cat dog'.split()
print Counter(words) # Counter({'dog': 2, 'cat': 1})
That makes sense. It is expected. Now, if things worked your way, we'd have this:
dicts = [{}, {}]
print Counter(dicts) # Counter({{}: 1, {}: 1})
That is NOT the first thing I would expect. You could explain it to me, but the first time I came across it (especially if I was new to programming) it would probably cause me quite some frustration while debugging. And even after understanding it it would probably catch me off guard once in a while. So while the language could be designed in your way, it would not be user friendly.
Similarly, dictionaries could be hashed based on content, and that would make the above snippet behave more intuitively. But now if I mutate the key I'm in serious trouble. I could be warned not to, but rather have the language protect me from making this kind of mistake than giving me all the freedom I want to shoot myself in the foot.
A better way to go would be to use an immutable dict
, which you can get here.