code: def equalspairs(X, Y):
      
      T = Y.copy()
      R = (T[1:] != T[:-1]).nonzero()[0]
      R = np.append(R,np.array([len(T)-1]))
      M = R[R.searchsorted(range(len(T)))]
      D = T.searchsorted(X)
      T = np.append(T,np.array([0]))
      M = np.append(M,np.array([0]))
      A = (T[D] == X) * D
      B = (T[D] == X) * (M[D] + 1)
      return [A,B]
docs: Indices of elements in a sorted numpy array equal to those in another.
  
      Given numpy array `X` and sorted numpy array `Y`, determine the indices in 
      Y equal to indices in X.
  
      Returns `[A,B]` where `A` and `B` are numpy arrays of indices in `X` such 
      that::
  
              Y[A[i]:B[i]] = Y[Y == X[i]]`
  
      `A[i] = B[i] = 0` if `X[i]` is not in `Y`.
  
      **Parameters**
  
              **X** :  numpy array
  
                      Numpy array to compare to the sorted numpy array `Y`.
  
              **Y** :  numpy array
  
                      Sorted numpy array.  Determine the indices of elements of 
                      `Y` equal to those in numpy array `X`.
  
      **Returns**
  
              **A** :  numpy array
  
                      List of indices in `Y`, `len(A) = len(Y)`.
  
              **B** :  numpy array
  
                      List of indices in `Y`, `len(B) = len(Y)`.
  
      **See Also:**
  
              :func:`tabular.fast.recarrayequalspairs`