[Numpy-discussion] Numeric 24.0
faltet at carabos.com
Tue Apr 19 03:05:27 EDT 2005
I was curious about the newly introduced array protocol in Numeric
24.0 (as well as in current numarray CVS), and wanted to check if
there is better speed during Numeric <-> numarray objects conversion.
There answer is "partially" affirmative:
>>> import numarray
>>> import Numeric
>>> print numarray.__version__
>>> print Numeric.__version__
>>> from time import time
>>> a = numarray.arange(100*1000)
>>> t1=time();b=Numeric.array(a);time()-t1 # numarray --> Numeric
0.0021419525146484375 # It was 1.58109998703 with Numeric 23.8 !
So, numarray --> Numeric speed has been improved quite a lot
On the other way round, Numeric to numarray is not as efficient:
>>> Na = Numeric.arange(100*1000)
>>> t1=time();c=numarray.array(Na);time()-t1 # Numeric --> numarray
0.15217900276184082 # It is much slower than numarray --> Numeric
I guess that the numarray --> Numeric can be speed-up because:
0.00017499923706054688 # Numeric --> numarray using the buffer protocol
So, I guess CVS numarray is still refining the array protocol.
But the thing that mostly shocks me is why the array protocol is still
allowing doing conversions with memory copies because, as you can see
in the last example that uses a buffer protocol, a non-copy memory
conversion is indeed possible for numarray --> Numeric.
So the question is: Would the array protocol bring numarray <->
Numeric <-> Numeric3 conversions without memory copies or this is more
a wish on my half than an actual possibility?
Thanks and keep the nice work!
>0,0< Francesc Altet http://www.carabos.com/
V V Cárabos Coop. V. Enjoy Data
More information about the NumPy-Discussion