Re: [Numpy-discussion] fast duplicate of array

2010-01-23 Thread Anne Archibald
2010/1/23 Alan G Isaac ais...@american.edu: Suppose x and y are conformable 2d arrays. I now want x to become a duplicate of y. I could create a new array: x = y.copy() or I could assign the values of y to x: x[:,:] = y As expected the latter is faster (no array creation). Are there

Re: [Numpy-discussion] fast duplicate of array

2010-01-23 Thread Alan G Isaac
On 1/23/2010 5:01 PM, Anne Archibald wrote: If both arrays are C contiguous, or more generally contiguous blocks of memory with the same strided structure, you might get faster copying by flattening them first, so that it can go in a single memcpy(). I may misuderstand this. Did you just

Re: [Numpy-discussion] fast duplicate of array

2010-01-23 Thread Keith Goodman
On Sat, Jan 23, 2010 at 2:31 PM, Alan G Isaac ais...@american.edu wrote: On 1/23/2010 5:01 PM, Anne Archibald wrote: If both arrays are C contiguous, or more generally contiguous blocks of memory with the same strided structure, you might get faster copying by flattening them first, so that it

Re: [Numpy-discussion] fast duplicate of array

2010-01-23 Thread Charles R Harris
On Sat, Jan 23, 2010 at 4:00 PM, Keith Goodman kwgood...@gmail.com wrote: On Sat, Jan 23, 2010 at 2:31 PM, Alan G Isaac ais...@american.edu wrote: On 1/23/2010 5:01 PM, Anne Archibald wrote: If both arrays are C contiguous, or more generally contiguous blocks of memory with the same

Re: [Numpy-discussion] fast duplicate of array

2010-01-23 Thread Anne Archibald
2010/1/23 Alan G Isaac ais...@american.edu: On 1/23/2010 5:01 PM, Anne Archibald wrote: If both arrays are C contiguous, or more generally contiguous blocks of memory with the same strided structure, you might get faster copying by flattening them first, so that it can go in a single

Re: [Numpy-discussion] fast duplicate of array

2010-01-23 Thread Alan G Isaac
On 1/23/2010 6:00 PM, Keith Goodman wrote: x = y.view() Thanks, but I'm not looking for a view. And I need x to own its data. Alan ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion

Re: [Numpy-discussion] fast duplicate of array

2010-01-23 Thread Alan G Isaac
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]: