title: Check if elements in array A belongs to array B
body: <p>I would like to check if the integers in a large array A belongs to a smaller array B in an efficient way. I currently do this using a for loop, which is simply too slow for large A and B. </p>
  
  <p>Any suggestions on how to do this in a more efficient way?</p>
  
  <p>Current code: </p>
  
  <pre><code>import numpy as np
  
  A=np.arange(10)
  B=np.array([0,1,9])
  isIn=np.zeros_like(A,dtype=bool)
  for i in np.unique(B):
     isIn[A==i]=True
  print(isIn)
  </code></pre>
  
  <pre><code>[ True  True False False False False False False False  True]
  </code></pre>