Implement BiDict, a mapping where values are unique and you can look up either way:
b[key] = value, b[key], del b[key], len(b), key in b, iteration over keysb.inverse[value] returns the key; b.inverse is itself a BiDict view that stays in sync (setting b.inverse[v] = k also updates b)ValueError; re-assigning a key to a new value removes the old value from the inverseSubclass collections.abc.MutableMapping so you get get, items, update and friends for free.