title: Efficient way to compute intersecting values between two numpy arrays
body: <p>I have a bottleneck in my program which is caused by the following:</p>
  
  <pre><code>A = numpy.array([10,4,6,7,1,5,3,4,24,1,1,9,10,10,18])
  B = numpy.array([1,4,5,6,7,8,9])
  
  C = numpy.array([i for i in A if i in B])
  </code></pre>
  
  <p>The expected outcome for <code>C</code> is the following:</p>
  
  <pre><code>C = [4 6 7 1 5 4 1 1 9]
  </code></pre>
  
  <p>Is there a more efficient way of doing this operation?</p>
  
  <p>Note that array <code>A</code> contains repeating values and they need to be taken into account. I wasn't able to use set intersection since taking the intersection will omit the repeating values, returning just <code>[1,4,5,6,7,9]</code>.</p>
  
  <p>Also note this is only a simple demonstration. The actual array sizes can be in the order of thousands, to well over millions.</p>