def in1d_sorted(ar1, ar2):
if ar1.shape[<NUM_LIT:0>] == <NUM_LIT:0> or ar2.shape[<NUM_LIT:0>] == <NUM_LIT:0>:  <EOL><INDENT>return []<EOL><DEDENT>inds = ar2.searchsorted(ar1)<EOL>inds[inds == len(ar2)] = <NUM_LIT:0><EOL>return ar2[inds] == ar1<EOL>
Does the same than np.in1d but uses the fact that ar1 and ar2 are sorted. Is therefore much faster.