[Numpy-discussion] Plain array performance

Magnus Lie Hetland magnus at hetland.org
Mon Feb 10 12:38:04 CST 2003


Just curious: What is the main strength of the array module in the
standard library? Is it footprint/memory usage? Is it speed? If so, at
what sizes? I ran some simple benchmarks (creating a list/array,
iterating over them to sum up their elements, and extracting the slice
foo[::2]) and got the following rations (array_time/list_time) for
various sizes:

Size 100:
Creation: 1.13482142857
Sum: 1.54649265905
Slicing: 1.53736654804

Size 1000:
Creation: 1.62444133147
Sum: 1.18439932835
Slicing: 1.56350184957

Size 10000:
Creation: 1.61642712328
Sum: 1.47768567821
Slicing: 1.45889354599

Size 100000:
Creation: 1.72711084285
Sum: 0.952593142445
Slicing: 1.05782341361

Size 1000000:
Creation: 1.56617139425
Sum: 0.735687066032
Slicing: 0.773219364465

Size 10000000:
Creation: 1.57903195174
Sum: 0.727253180418
Slicing: 0.726005428022

These benchmarks are pretty naïve, but it seems to me that unless
you're working with quite large arrays, there is no great advantage to
using arrays rather than lists... (I'm not including numarray or
Numeric in the equation here -- I just raise the issue because of the
use of arrays in Psymeric...)

Just curious...

-- 
Magnus Lie Hetland               "Nothing shocks me. I'm a scientist." 
http://hetland.org                                   -- Indiana Jones




More information about the Numpy-discussion mailing list