def recarrayuniqify(X, retainorder=False):
N = X.dtype.names<EOL>s = X.argsort(order=N)<EOL>s = s.view(np.ndarray)<EOL>X = X[s]<EOL>D = np.append([True],X[<NUM_LIT:1>:] != X[:-<NUM_LIT:1>])<EOL>if retainorder:<EOL><INDENT>DD = np.append(D.nonzero()[<NUM_LIT:0>],len(X))<EOL>ind = [min(s[x:DD[i+<NUM_LIT:1>]]) for (i,x) in enumerate(DD[:-<NUM_LIT:1>])]<EOL>ind.sort()<EOL>return ind<EOL><DEDENT>else:<EOL><INDENT>return [D,s]<EOL><DEDENT>
Very fast uniqify routine for numpy record arrays (or ndarrays with 
structured dtype).

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

**Parameters**

        **X** :  numpy recarray

                Determine the unique elements of this numpy recarray.

        **retainorder** :  Boolean, optional

                Whether or not to return indices corresponding to unique 
                values of `X` that also sort the values.  Default value is 
                `False`, in which case `[D,s]` is  returned.  This can be 
                used to produce a uniqified  version of `X` by simply 
                taking::

                        X[s][D]

                or::

                        X[s[D.nonzero()[0]]]

**Returns**

        **D** :  numpy recarray

                List of "first differences" in the sorted verion of `X`.  
                Returned when `retainorder` is `False` (default).

        **s** :  numpy array

                Permutation that will sort `X`.  Returned when 
                `retainorder` is `False` (default).

        **ind** :  numpy array

                List of indices that correspond to unique values of `X`, 
                without sorting those values.  Returned when `retainorder` 
                is `True`.

**See Also:**

        :func:`tabular.fast.arrayuniqify`