[Numpy-discussion] Array vectorization in numpy

Pauli Virtanen pav at iki.fi
Wed Jul 20 05:04:09 EDT 2011


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.

If it would come from pre-allocation, how come I get the same speed
as an equivalent C implementation, which *does* pre-allocation, using
exactly the same benchmark codes as you have posted?

-- 
Pauli Virtanen




More information about the NumPy-Discussion mailing list