Numeric vs numarray speed

jsaul jsaul at
Tue Oct 15 11:54:34 CEST 2002

* Nick B [2002-10-13 11:05]:
> I have some image processing code that runs fine under Py2.1 and Py2.2 with
> Numeric.  Trying the same thing under the upcoming successor numarray (just
> global find-and-replace numarray for Numeric in my code) it runs, but way
> slower than 1/10 the speed.  So for now I'm sticking to Numeric.
> Anyone any ideas why.  Is numarray full of debug code ?

Though I have not compared the codes yet, I can second your
observation as to the inferior performance of numarray vs.
Numeric. The difference can be even worse than a factor of 10.
For example, a simple seismic analysis code doing component
rotation via matrix multiplication on time series plus some
I/O takes about 29 seconds with Numeric (15 MB of binary data),
whereas after substituting Numeric with numarray it takes an
unacceptably long 640 seconds!

Numarray appears to be particularly slow at element-wise
operations on arrays (resulting in the above numbers), i.e.
operations which are expected to be rather inefficient. Use
of the corresponding 'Ufuncs' significantly increased the
speed: 36 (numarray) vs. 13 (Numeric) seconds. Not always
one can take advantage of the superior performance of ufuncs,
of course.

For comparison, a C++ program performs the corresponding
computations (including I/O) in about 5 seconds on the same
machine and data set, without sophisticated optimizations.
Therefore, I find Numeric's performance is not quite bad
taking into account the usual Python overhead. I would not
(yet) consider numarray an alternative to Numeric, for my
purpose at least.

I would be interested to see examples of numarray outperforming

Gruß, jsaul
Que le gusta rrrodarrr la errre.

More information about the Python-list mailing list