numarray.array can be VERY slow

Robert Kern rkern at ucsd.edu
Wed Apr 13 18:57:24 EDT 2005


Jim wrote:
> Edward C. Jones wrote:
> 
>> Steven Bethard wrote:
>>
>>  > As mentioned, this has nothing to do with numarray, and everything to
>>  > do with your inexplicable use of lists.  Why don't you just write this
>>  > as:
>>  >
>>  > arr = numarray.ones((8, 8, 256, 256), Float64)
>>
>> The code I posted was simplified from a larger program which I have 
>> now revised. But I still ask: why did it take 4.3 seconds to run?
> 
> 
> Is the simple answer not that repeated use of array.append is 
> inefficient as python has to repeatedly re-allocate memory for the array?

No, because he wasn't appending to arrays, he was appending to lists 
(each only 8 items long, so there really is no significant overhead). 
See my response in this thread for the answer.

-- 
Robert Kern
rkern at ucsd.edu

"In the fields of hell where the grass grows high
  Are the graves of dreams allowed to die."
   -- Richard Harter




More information about the Python-list mailing list