title: Efficient data structure of objects in python for lookup based on any object member variable
body: <p>I need to store objects that have a number (>2) of integer member variables and do quick look-ups using any member variables as a search key.</p>
  
  <p>For easier illustration let's say the objects are tuples of 3 integers and I need to do quick look-ups using any element of a tuple as a key in a list of such tuples:</p>
  
  <pre><code>collection = [(1, 200, 9), 
                (2, 300, 8), 
                (3, 400, 7)]
  </code></pre>
  
  <p>Look-ups would be like:</p>
  
  <pre><code>collection.lookup_by_first_element(1) # Return (1, 200, 9)
  collection.lookup_by_second_element(300) # Return (2, 300, 8)
  collection.lookup_by_third_element(250) # Return None
  </code></pre>
  
  <p>I need the lookups to be fast/efficient. My best bet so far is to use an in memory sqlite database with three columns for the three tuple elements and put indexes on all three columns.</p>
  
  <p>A search tree would also do, but those have one key for lookup and I don't see how could I do lookups based on more than one key. How would you do it?</p>