[Numpy-discussion] array creation speed comparison
Eric Firing
efiring at hawaii.edu
Tue Jun 20 15:33:57 CDT 2006
In the course of trying to speed up matplotlib, I did a little
experiment that may indicate a place where numpy can be sped up: the
creation of a 2-D array from a list of tuples. Using the attached
script, I find that numarray is roughly 5x faster than either numpy or
Numeric:
[efiring at manini tests]$ python test_array.py
array size: 10000 2
number of loops: 100
numpy 10.89
numpy2 6.57
numarray 1.77
numarray2 0.76
Numeric 8.2
Numeric2 4.36
[efiring at manini tests]$ python test_array.py
array size: 100 2
number of loops: 100
numpy 0.11
numpy2 0.06
numarray 0.03
numarray2 0.01
Numeric 0.08
Numeric2 0.05
The numarray advantage persists for relatively small arrays (100x2;
second example) and larger ones (10000x2; first example). In each case,
the second test for a given package (e.g., numpy2) is the result with
the type of the array element specified in advance, and the first (e.g.,
numpy) is without such specification.
The versions I used are:
In [3]:Numeric.__version__
Out[3]:'24.0b2'
In [5]:numarray.__version__
Out[5]:'1.4.1'
In [7]:numpy.__version__
Out[7]:'0.9.9.2584'
Eric
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test_array.py
Type: text/x-python
Size: 890 bytes
Desc: not available
Url : http://projects.scipy.org/pipermail/numpy-discussion/attachments/20060620/1deae12d/attachment-0001.py
More information about the Numpy-discussion
mailing list