
14 May
2003
14 May
'03
1:08 p.m.
On Wed, 14 May 2003, Perry Greenfield wrote:
import numarray a = numarray.arange(6) a
array([0, 1, 2, 3, 4, 5])
a[:] = 0.0 a
array([0, 0, 0, 0, 0, 0])
Is there any reason for anything else if this does the job? This is how I would recommend the action be performed.
It depends. How does the slicing code work?
If it iterates across the matrix indicies (requiring multiply and add operations to index specific memory locations), this will be much slower than doing a contiguous memory fill (1 add and 1 multiply per index vs. increment). This is not a small hit, we're talking factors of 2x, 4x, 6x.
If the slicing code special cases "array[:] = n" to be a memory fill, then probably not.
-a