I am modeling data for an application and decided to choose dictionary as my data structure. But each row in the data has multiple keys. So I created a dictionary with multiple keys mapping each row, something like:
>>> multiKeyDict = {}
>>> multiKeyDict[('key1','key2','key3')] = 'value1'
>>> multiKeyDict.get(('key1','key2','key3'))
'value1'
Now I have to retrieve all the values with key1
in O(1) time. From my research I know I could do:
- use this package to get the job done but not sure if it is O(1)
- search for keys as suggested here: https://stackoverflow.com/a/18453567/4085019
I am also open for any better data structures instead of using the dictionary.