`unique_n` can be preallocated. 

The repeated calls to `count` will get expensive, approximately O(N*M) where N is the length of `gl_unique` and M is the length of `grouping`. The counts I believe can be done with a single call to `np.bincount`.