[Numpy-discussion] Using sum() within a function

jimcser at pacifier.com jimcser at pacifier.com
Mon Aug 16 13:29:03 EDT 2004

> Jim Cser wrote:
>> The loop was indeed wrong, and "tempval = 0.*x" was the trick I needed,
>> thanks.  Unfortunately, iterating over t is still extremely slow.
>> Ideally, there would be a way to use fromfunction() with slices as
>> arguments.
> If the other 3 dimensions are small (e.g., each time sample
> involves an array whose size is less than 1000 elements total),
> then the slowness is due to the small arrays. In that event
> you may want iterate over a different dimension than time, or
> construct the for loop to iterate over ranges of times rather
> than one at a time.
> Perry

I was just using T as a sample name, so I am not actually doing
a time series of anything.  My dimesions are on the order of
numT = 500, numX = 500, numY = 100, numZ = 10, so smallness is not
the problem.  Unfortunately, I don't need to sum over Z, the short
dimension.  If my system didn't hang, I would have done it the
easier way in the first place.

Perhaps I need to learn more about memory management-- I'm sure
that many Python users are crunching bigger even arrays than this.
For what it's worth, I'm using Python 2.3 / Numarray 1.0 with
PythonWin on an XP box, 512M RAM.


More information about the NumPy-Discussion mailing list