Consider a very large Python dictionary of the like:
some_dict = {
"val_1": "val_a",
"val_2": "val_b",
"val_x": "val_1",
"val_y": "val_2",
### millions of one-to-one key-value pairs
### note that keys and values can overlap
}
I would like to use this dictionary to efficiently convert/translate data from one representation to another (and back). What is the most efficient way of achieving this?
One option is to create some_dict_reversed
and then use dictionary looks ups for inverse conversion, but I would like to avoid duplicating the data. There must be a better way.