I know dictionaries are fast when it comes to looking up a key but is it a waste, especially in respect to memory, to have two dictionaries point to the same exact same objects but with different yet relevant keys so you can use those keys to look up elements in different ways. In my application lookup speed is more important than the time to arrange the set of data.
Ex: you have a large set containing driver's license information. You store the information in a Dictionary with the key being their respective name on the drivers license. You also create a second Dictionary pointing to the same objects as the key but with the drivers license ID number as the key
class DL:
def __init__(self, name, id):
self.name = name
self.id = id
licenses = {DL('jon', 1), DL('joe', 2), DL('jack', 3), DL('jill', 4)}
byName = dict()
byID = dict()
for i in licenses:
byName[i.name] = i
byID[i.id] = i
print(byName)
print(byID)