[Numpy-discussion] Array vectorization in numpy

Christopher Jordan-Squire cjordan1 at uw.edu
Tue Jul 19 12:44:54 EDT 2011


On Tue, Jul 19, 2011 at 11:19 AM, Charles R Harris <
charlesr.harris at gmail.com> wrote:

>
>
> 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
>

Also what version of matlab were you using?

-Chris JS


>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20110719/1e6ebf2f/attachment.html>


More information about the NumPy-Discussion mailing list