[Numpy-discussion] Array vectorization in numpy

Pauli Virtanen pav at iki.fi
Wed Jul 20 05:17:14 EDT 2011


Wed, 20 Jul 2011 09:04:09 +0000, Pauli Virtanen wrote:

> Wed, 20 Jul 2011 08:49:21 +0200, Carlos Becker wrote:
>> Those are very interesting examples. I think that pre-allocation is
>> very important, and something similar happens in Matlab if no
>> pre-allocation is done: it takes 3-4x longer than with pre-allocation.
>> The main difference is that Matlab is able to take into account a
>> pre-allocated array/matrix, probably avoiding the creation of a
>> temporary and writing the results directly in the pre-allocated array.
> 
> You have not demonstrated that the difference you have comes from
> pre-allocation.

Also, there are no temporaries in the expression

	k = m - 0.5




More information about the NumPy-Discussion mailing list