[Numpy-discussion] fast duplicate of array

Alan G Isaac aisaac@american....
Sat Jan 23 18:39:42 CST 2010


On 1/23/2010 7:29 PM, Anne Archibald wrote:
> I had in mind accessing the underlying data through views
> that were flat:
>
> In [3]: x = np.random.random((1000,1000))
>
> In [4]: y = np.random.random((1000,1000))
>
> In [5]: xf = x.view()
>
> In [6]: xf.shape = (-1,)
>
> In [7]: yf = y.view()
>
> In [8]: yf.shape = (-1,)
>
> In [9]: yf[:] = xf[:]


Yup, that's a bit faster.
Thanks,
Alan



More information about the NumPy-Discussion mailing list