[Numpy-discussion] fast duplicate of array

Alan G Isaac aisaac at american.edu
Sat Jan 23 19:39:42 EST 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