title: Fastest way to filter a numpy array by a set of values
body: <p>I am pretty new to numpy, I also am using pypy 2.2 which has limited numpy support (see <a href="http://buildbot.pypy.org/numpy-status/latest.html" rel="noreferrer">http://buildbot.pypy.org/numpy-status/latest.html</a>) but what I'm trying to do is filter an array by a set of values (i.e keep subarray if it contains a value in a set). I can do with a list comprehension but I'd rather do without the intermediate list as on longer arrays it isn't fast and I can't help but think numpy filtering will be faster.</p>
  
  <pre><code>&gt;&gt; a = np.array([[   368,    322, 175238,      2],
         [   430,    382, 121486,      2],
         [   451,    412, 153521,      2],
         [   480,    442, 121468,      2],
         [   517,    475, 109543,      2],
         [   543,    503, 121471,      2],
         [   576,    537, 100566,      2],
         [   607,    567, 121473,      2],
         [   640,    597, 153561,      2]])
  
  &gt;&gt; b = {121486, 153521, 121473}
  
  &gt;&gt; np.array([x for x in a if x[2] in b])
  
  &gt;&gt; array([[   430,    382, 121486,      2],
     [   451,    412, 153521,      2],
     [   607,    567, 121473,      2]])
  </code></pre>