Search set, return item Is there a more efficient way of achieving the same result besides setting up a database?

# In reality, contains 4 million tuples.
stuff_tuple = (
    ('hello', 241, 1),
    ('hi', 243, 3),
    ('hey', 242, 2)
)

# Convert tuple to set for faster searching?
stuff_set = set(stuff_tuple)

# Only first two values are known ("hello", 241), ('hi', 243), etc.
for item in stuff_set:
    if item[0] == 'hello' and item[1] == 241:
        print item[2]
If all your queries are similar to the example, you would obviously benefit from storing the data in a dict where a tuple of two values is the key, and the value is a list of ints -- all of the third items that share the same key.

from collections import defaultdict

stuff_dict = defaultdict(list)
for t in stuff_tuple:
    stuff_dict[t[:2]].append(t[2])

for item in stuff_dict['hello', 241]:
    print item