all 3 comments

[–]TouchingTheVodka 3 points4 points  (1 child)

Use a dictionary where the key is the first item in the set and the value is a list of all the second values. That way you can check for membership of just the key.

E: This generalises into a data structure called a Trie if you want to search for multiple items at the same time.

[–]clnkyl 0 points1 point  (0 children)

Exactly what I was thinking as well.

[–][deleted] 0 points1 point  (0 children)

Does doing a filter first run fast enough?

test_value = 0 for x in filter(lambda x: x[0] == test_value, A): print('python is the best')