I am trying to work with a dictionary with tuples of n values as keys. I want to find tuples whose 2nd value is 10 (for example)
('HI', '10', '10', '10', '10', '10000', 'true', '0.5GiB', '8', '100000s', '100MiB')
('HI', '100', '10', '10', '10', '100', 'false', '0.5GiB', '8', '100000s', '100MiB')
('HI', '100', '10', '10', '10', '1000', 'true', '0.7GiB', '8', '1000s', '100MiB')
Any ideads how I can do it? THanks!
For that particular scenario, you’d have to iterate over all of the keys and test them against your predicate:
If you wanted to do this more quickly for repeated lookups and you knew ahead of time what field(s) you’d be checking, you could build indices that map between values for a particular index in each tuple to the keys that have a given value:
And then you could just use that to look up a particular value: