Indices of elements in a numpy record array (or ndarray with structured 
    dtype) that appear in another.

    Fast routine for determining indices of elements in numpy record array `X` 
    that appear in numpy record array `Y`, returning a boolean array `Z` such 
    that::

            Z[i] = X[i] in Y

    Record array version of func:`tabular.fast.isin`.

    **Parameters**

            **X** :  numpy recarray

                    Numpy recarray to comapare to numpy recarray `Y`.  For each 
                    element of `X`, ask if it is in `Y`.

            **Y** :  numpy recarray

                    Numpy recarray to which numpy recarray `X` is compared.  
                    For each element of `X`, ask if it is in `Y`.

    **Returns**

            **b** :  numpy array (bool)

                    Boolean numpy array, `len(b) = len(X)`.

    **See Also:**

            :func:`tabular.fast.isin`, :func:`tabular.fast.recarraydifference`

def recarrayisin(X,Y,weak=True):
    """
    Indices of elements in a numpy record array (or ndarray with structured 
    dtype) that appear in another.

    Fast routine for determining indices of elements in numpy record array `X` 
    that appear in numpy record array `Y`, returning a boolean array `Z` such 
    that::

            Z[i] = X[i] in Y

    Record array version of func:`tabular.fast.isin`.

    **Parameters**

            **X** :  numpy recarray

                    Numpy recarray to comapare to numpy recarray `Y`.  For each 
                    element of `X`, ask if it is in `Y`.

            **Y** :  numpy recarray

                    Numpy recarray to which numpy recarray `X` is compared.  
                    For each element of `X`, ask if it is in `Y`.

    **Returns**

            **b** :  numpy array (bool)

                    Boolean numpy array, `len(b) = len(X)`.

    **See Also:**

            :func:`tabular.fast.isin`, :func:`tabular.fast.recarraydifference`

    """
    if (weak and set(X.dtype.names) != set(Y.dtype.names)) or \
       (not weak and X.dtype.names != Y.dtype.names):
        return np.zeros((len(X),),bool)
    else:
        if X.dtype.names != Y.dtype.names:
            Y = np.rec.fromarrays([Y[a] for a in X.dtype.names], 
                                  names=X.dtype.names)
        NewX = np.array([str(l) for l in X])
        NewY = np.array([str(l) for l in Y])
        NewY.sort()
        return isin(NewX,NewY)