[Numpy-discussion] Numpy performance vs Matlab.

Robert Kern robert.kern@gmail....
Wed Jan 7 14:54:50 CST 2009

On Wed, Jan 7, 2009 at 10:19, Nicolas ROUX <nicolas.roux@st.com> wrote:
> Hi,
> I need help ;-)
> I have here a testcase which works much faster in Matlab than Numpy.
> The following code takes less than 0.9sec in Matlab, but 21sec in Python.
> Numpy is 24 times slower than Matlab !
> The big trouble I have is a large team of people within my company is ready to replace Matlab by Numpy/Scipy/Matplotlib,
> but I have to demonstrate that this kind of Python Code is executed with the same performance than Matlab, without writing C extension.
> This is becoming a critical point for us.
> This is a testcase that people would like to see working without any code restructuring.

Basically, if you want efficient numpy code, you have to use numpy
idioms. If you want to continue to use Matlab idioms, keep using

> The reasons are:
> - this way of writing is fairly natural.
> - the original code which showed me the matlab/Numpy performance differences is much more complex,
> and can't benefit from broadcasting or other numpy tips (I can later give this code)

Please do. Otherwise, we can't actually address your concerns.

Robert Kern

"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
  -- Umberto Eco

More information about the Numpy-discussion mailing list