[Numpy-discussion] Is there a pure numpy recipe for this?
Chris Barker
chris.barker at noaa.gov
Wed Mar 26 18:13:51 EDT 2014
On Wed, Mar 26, 2014 at 2:23 PM, Slaunger <Slaunger at gmail.com> wrote:
> Only I did not know about the append and insert methods. Very, very nice!
> (I
> only knew concatenate, which would be clumsy for just appending one
> element),
>
Sorry -- I dont have the time to actually figure out what you are doing,
but:::
note that numpy arrays are not re-sizable, so np.append() and np.insert()
have to make a new array, and copy all the old data over. If you are
appending one at a time, this can be pretty darn slow.
I wrote a "grow_array" class once, it was a wrapper around a numpy array
that pre-allocated extra data to make appending more efficient. It's kind
of half-baked code now, but let me know if you are interested.
-Chris
--
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chris.Barker at noaa.gov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20140326/cf179742/attachment.html>
More information about the NumPy-Discussion
mailing list