[Numpy-discussion] String manipulation summary

Christopher Barker Chris.Barker at noaa.gov
Mon Jul 27 20:00:38 EDT 2009


Chris Colbert wrote:
> what machine spec are you using?

Dual 2Ghz PPC OS-X 10.4. Python2.5, numpy 1.3.0rc1 (hmm -- I should 
upgrade that!)


> Using your last function line2array5 WITH float conversion, i get the
> following timing on a mobile quad core extreme:
> 
> In [24]: a = np.arange(100).astype(str).tostring()
> 
> In [25]: a
> Out[25]: '0123456789111111111122222222223333333333444444444455555555556666666666777777777788888888889999999999'
> 
> In [26]: %timeit line2array(a, 1)
> 10000 loops, best of 3: 37.1 µs per loop
> 
> In [27]: a = np.arange(1000).astype(str).tostring()
> 
> In [28]: %timeit line2array(a, 10)
> 10000 loops, best of 3: 45.2 µs per loop

and I get, timing it the same way (I forgot about ipython's timeit!):

In [83]: %timeit line2array5(a, 1)
10000 loops, best of 3: 125 µs per loop

In [84]: a = np.arange(1000).astype(str).tostring()

In [85]: %timeit line2array5(a, 1)
1000 loops, best of 3: 1.09 ms per loop

similar to yours, but longer with an older machine. I wonder why my 
other timings came out the way they did?

-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



More information about the NumPy-Discussion mailing list