I have a set (potentially a very large number) of values generated at random, which I need to have quick access to and so from both sides. meaning:
take a tuple:
(133: 42)
one way:
getIDfromValue(42)
>>>133
the other:
getValuefromID(133)
>>>42
the way i have been doing this so far is by making two dictionnaries and accessing one or the other depending the need. like:
values = {42:133, ...}
ids = {133:42, ...}
values[42]
>>>133
ids[133]
>>>42
but that doesn't feel quite nor right nor efficient. how would one do this?
(subsidiary question: is a argument of dictionary accessed directly in memory, or is the dictionary iterated?)
thanks a lot