Python Speedup np.unique

numpy, performance, python

Solution

`numpy.unique` is already pretty optimized, you're not likely to get get much of a speedup over what you already have unless you know something else about the underlying data. For example if the data is all small integers you might be able to use `numpy.bincount` or if the unique values in each of the arrays are mostly the same there might be some optimization that could be done over the whole list of arrays.

Problem

I am looking to speed up the following piece of code: ``` NNlist=[np.unique(i) for i in NNlist] ``` where NNlist is a list of np.arrays with duplicated entries. Thanks :)

Original source