Re: [Numpy-discussion] fromfile() for reading text (one more time!)

2010-01-23 Thread alan
On Mon, Jan 4, 2010 at 10:39 PM, a...@ajackson.org wrote: Hi folks, I'm taking a look once again at fromfile() for reading text files. I often have the need to read a LOT of numbers form a text file, and it can actually be pretty darn slow do i the normal python way: .big

Re: [Numpy-discussion] fromfile() for reading text (one more time!)

2010-01-23 Thread Christopher Barker
a...@ajackson.org wrote: it doesn't support the reasonable (IMHO) behavior of treating quote delimited strings in the input file as a single field. I'd use the csv module for that. Which makes me wonder if it might make sense to build some of the numpy table-reading stuff on top of it...

Re: [Numpy-discussion] fromfile() for reading text (one more time!)

2010-01-23 Thread josef . pktd
On Sat, Jan 23, 2010 at 1:53 PM, Christopher Barker chris.bar...@noaa.gov wrote: a...@ajackson.org wrote: it doesn't support the reasonable (IMHO) behavior of treating quote delimited strings in the input file as a single field. I'd use the csv module for that. Which makes me wonder if it

[Numpy-discussion] fast duplicate of array

2010-01-23 Thread Alan G Isaac
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 better ways? Thanks, Alan Isaac

[Numpy-discussion] random v. random_state in RandomState

2010-01-23 Thread Alan G Isaac
As I understand it, numpy.random provides the function ``random`` as an alias for ``random_state``. Might this be moved into numpy.random.mtrand.RandomState, for interface consistency? Right now if I start with ``prng = np.random.RandomState(seed=myseed)`` I cannot use ``prng.random`` as it does

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]: