def _fast_count_smallints(arr):
 if (len(arr) == 0):
  return np.empty((0, 2), dtype=arr.dtype)
 else:
  counts = np.bincount(arr.astype(np.int_))
  nz = counts.nonzero()[0]
  return np.c_[(nz, counts[nz])]

def _fast_count_smallints ( arr ) : if ( len ( arr ) == 0 ) : return np . empty ( ( 0 , 2 ) , dtype = arr . dtype ) else : counts = np . bincount ( arr . astype ( np . int_ ) ) nz = counts . nonzero ( ) [ 0 ] return np . c_ [ ( nz , counts [ nz ] ) ]
faster version of set for sequences of small numbers .