title: Looking up large sets of keys: dictionary vs. NumPy array
body: <p>I have a very large (200k+) set of key/value pairs, for which I need to retrieve very large (sometimes all) of the values. The obvious way to do this is with a dictionary such that</p>
  
  <pre><code> values = {lookup.get(key) for key in key_set}
  </code></pre>
  
  <p>This is getting very time consuming in my code, and I'm wondering if there's a faster way to implement this with a NumPy array. I've been experimenting with using an array with two columns and n rows, such that for any individual key:</p>
  
  <pre><code>value = lookup_array[lookup_array[:,0] == key, 1]
  </code></pre>
  
  <p>But I'm not sure how to scale this to many keys up without costly iteration. I've looked at:</p>
  
  <pre><code>values = lookup_array[np.in1d(lookup_array[:,0], key_set), 1]
  </code></pre>
  
  <p>but this also seems time consuming.</p>
  
  <p>Is there any other way to do a massive lookup of nonconsecutive values quickly without iterating?</p>