<div class="gmail_quote">On Wed, Sep 14, 2011 at 4:25 PM, Christopher Barker <span dir="ltr"><<a href="mailto:Chris.Barker@noaa.gov">Chris.Barker@noaa.gov</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

<div class="im">On 9/14/11 1:01 PM, Christopher Barker wrote:<br>
> numpy.ndarray.resize is a different method, and I'm pretty sure it<br>
> should be as fast or faster that np.empty + np.append.<br>
<br>
</div>My profile:<br>
<br>
In [25]: %timeit f1 # numpy.resize()<br>
10000000 loops, best of 3: 163 ns per loop<br>
<br>
In [26]: %timeit f2 #numpy.ndarray.resize()<br>
10000000 loops, best of 3: 136 ns per loop<br>
<br>
In [27]: %timeit f3 # numpy.empty() + append()<br>
10000000 loops, best of 3: 136 ns per loop<br>
<br>
<br>
those last two couldn't b more identical!<br>
<br>
(though this is an excercise in unrequired optimization!)<br>
<br></blockquote><div><br>Are you sure the f2 code works?  a.resize() takes only a shape tuple.  As coded, you should get an exception.<br><br>Ben Root<br><br></div></div>