[Numpy-discussion] load from text files Pull Request Review

Benjamin Root ben.root at ou.edu
Wed Sep 14 17:41:42 EDT 2011


On Wed, Sep 14, 2011 at 4:25 PM, Christopher Barker
<Chris.Barker at noaa.gov>wrote:

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

Ben Root
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20110914/de6de0cd/attachment.html>


More information about the NumPy-Discussion mailing list