I have a main numpy array a and I have another numpy array b. What I want to do is go through each element of b and check if that element exists in a. Keep in mind that both a and b are pretty massive, so I would like to avoid O(N) search times.
I know np.searchsorted(a,b) exists, but this provides an index at which I need to place b. This does not tell me if an element of b is present in a right off the bat.
My question is, is there a binary search algorithm built into numpy that simply reports True or False if an element from b exists in a? I am aware that I can write one but if there is a vectorized that is readily available, I could save some time.
Any advice would be appreciated!
aat the indices returned and compare with the values inb. For each value in b, if value == a[i], then the value exists in a, otherwise it does not. If the input is large, the benefit of vectorization probably outweighs the penalty for the O(1) lookups.