title: What is the best data structure for storing a set of four (or more) values?
body: <p>Say I have the following <code>variables</code> and its corresponding <code>values</code> which represents a <code>record</code>. </p>
  
  <pre><code>name = 'abc'
  age = 23
  weight = 60
  height = 174
  </code></pre>
  
  <p>Please note that the <code>value</code> could be of different <code>types</code> (<code>string</code>, <code>integer</code>, <code>float</code>, reference-to-any-other-object, etc). </p>
  
  <p>There will be many <code>records</code> (at least >100,000). Each and every <code>record</code> will be <code>unique</code> when all these four <code>variables</code> (actually its <code>values</code>) are put together. In other words, there exists no <code>record</code> with all 4 <code>values</code> are the same.</p>
  
  <p>I am trying to find an efficient data structure in <code>Python</code> which will allow me to (store and) retrieve <code>records</code> based on any one of these <code>variables</code> in <code>log(n)</code> time complexity. </p>
  
  <p>For example:</p>
  
  <pre><code>def retrieve(name=None,age=None,weight=None,height=None) 
      if name is not None and age is None and weight is None and height is None:
          /* get all records with the given name */
      if name is None and age is not None and weight is None and height is None:
          /* get all records with the given age */
      ....
      return records
  </code></pre>
  
  <p>The way the <code>retrieve</code> should be called is as follows: </p>
  
  <pre><code>retrieve(name='abc') 
  </code></pre>
  
  <p>The above should return <code>[{name:'abc', age:23, wight:50, height=175}, {name:'abc', age:28, wight:55, height=170}, etc]</code></p>
  
  <pre><code>retrieve(age=23) 
  </code></pre>
  
  <p>The above should return <code>[{name:'abc', age:23, wight:50, height=175}, {name:'def', age:23, wight:65, height=180}, etc]</code></p>
  
  <p>And, I may need to add one or two more <code>variables</code> to this record in future. For example, say, <code>sex = 'm'</code>. So, the <code>retrieve</code> function must be scalable.</p>
  
  <p>So in short: Is there a data structure in <code>Python</code> which will allow <code>storing a record</code> with <code>n</code> number of <code>columns</code> (name, age, sex, weigh, height, etc) and <code>retrieving records</code> based on any (one) of the <code>column</code> in <code>logarithmic</code> (or ideally <code>constant - O(1)</code> look-up time) complexity?  </p>