On Tue, Sep 21, 2010 at 12:43 PM, <[email protected]> wrote:
> I'm a bit surprised, I think np.unique does some extra work to
> maintain the order.
> The tolist() might not be necessary if you iterate over rows.
>
Testing again with a smaller k array and more repeats
I[25]: k = np.array((a.tolist()*5000))
I[27]: %timeit -r 100 np.array(list(set(tuple(i) for i in k.tolist())))
10 loops, best of 100: 31.3 ms per loop
I[28]: %timeit -r 100 np.array(list(set(tuple(i) for i in k)))
10 loops, best of 100: 55.4 ms per loop
I[30]: %timeit -r 100
np.unique(k.view([('',k.dtype)]*k.shape[1])).view(k.dtype).reshape(-1,k.shape[1])
10 loops, best of 100: 60.5 ms per loop
.tolist version is faster. Can you also verify this?
--
Gökhan
_______________________________________________
NumPy-Discussion mailing list
[email protected]
http://mail.scipy.org/mailman/listinfo/numpy-discussion