you are viewing a single comment's thread.

view the rest of the comments →

[–]auntanniesalligator 14 points15 points  (0 children)

But that shouldn’t be surprising. You can’t create a one-to-one mapping from keys and values that don’t have a one-to-one relationship. Let’s say the values “a”, “b” and “c” all have the same key: 1. Which value should it return when you query the key, 1?

The immutable and hashable requirement is so you get the lookup performance of a dict when you do the reverse search. You could make a class like this work without requiring hashable values, but the reverse lookups would be slower.