def _fast_count_smallints(arr):
    """Faster version of set(arr) for sequences of small numbers."""
    counts = np.bincount(arr.astype(np.int_))
    nz = counts.nonzero()[0]
    return np.c_[nz, counts[nz]]
def _fast_count_smallints ( arr ) : counts = np . bincount ( arr . astype ( np . int_ ) ) nz = counts . nonzero ( ) [ 0 ] return np . c_ [ nz , counts [ nz ] ]
Faster version of set(arr) for sequences of small numbers.