[Numpy-discussion] Array vectorization in numpy

Charles R Harris charlesr.harris at gmail.com
Tue Jul 19 12:19:07 EDT 2011


On Tue, Jul 19, 2011 at 9:49 AM, Carlos Becker <carlosbecker at gmail.com>wrote:

> I made more tests with the same operation, restricting Matlab to use a
> single processing unit. I got:
>
> - Matlab: 0.0063 sec avg
> - Numpy: 0.026 sec avg
> - Numpy with weave.blitz: 0.0041
>
> Note that weave.blitz is even faster than Matlab (slightly).
> I tried on an older computer, and I got similar results between matlab and
> numpy without weave.blitz, so maybe it has to do with 'new' vectorization
> opcodes.
>
> Anyhow, even though these results are not very promising, it gets worse if
> I try to do something like:
>
> result = (m - 0.5)*0.3
>
> and I get the following timings:
>
> - Matlab: 0.0089
> - Numpy: 0.051
> - Numpy with blitz: 0.0043
>
> Now blitz is considerably faster! Anyways, I am concerned about numpy being
> much slower, in this case taking 2x the time of the previous operation.
> I guess this is because of the way that python operands/arguments are
> passed. Should I always use weave.blitz?
>
>
Out of curiosity, what os/architecture are you running on? What version of
numpy are you using?

By and large, you shouldn't spend time programming in blitz, it will ruin
the whole point of using numpy in the first place. If there is an
inefficiency somewhere it is better to fix the core problem, whatever it is.

<numpy>

Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20110719/dffdb5db/attachment.html>


More information about the NumPy-Discussion mailing list