NumPy Slow ??
Travis Oliphant
olipt at mayo.edu
Mon Sep 18 18:17:27 EDT 2000
> Why is it that this line take ~30 sec to execute on a 500 MHz pentium III
> 128Meg RAM ?
>
> data1 = choose(greater(data,z2),(data,z2))
>
> where data is a 2048x2080 array of float and z2 is a float.
>
> I thought that NumPy functions where written in C for faster execution. Or
> maybe that I'm wrong and this is fast execution?
You are very likely creating a new 2048x2080 array of doubles (not floats)
with the comparison to a float (a Python float object is interpreted by
NumPy as a double). Some of the time is spent copying creating that new
array.
Try setting the savespace property:
data.savespace(1)
before you run that command to prevent this.
-Travis
More information about the Python-list
mailing list