[Numpy-discussion] optimising single value functions for array calculations

Timmie timmichelsen@gmx-topmail...
Mon Dec 1 04:22:10 CST 2008


Hello,
I am developing a module which bases its calculations
on another specialised module.
My module uses numpy arrays a lot.
The problem is that the other module I am building 
upon, does not work with (whole) arrays but with
single values.
Therefore, I am currently forces to loop over the
array:

###
a = numpy.arange(100)
b = numpy.arange(100,200)
for i in range(0,a.size):
    a[i] = myfunc(a[i])* b[i]

###

The results come out well. But the problem is that this
way of calculation is very ineffiecent and takes time.

May anyone give me a hint on how I can improve my 
code without having to modify the package I am
building upon. I do not want to change it a lot because
I would always have to run behind the chnages in the 
other package.

To summarise:
How to I make a calculation function array-aware?

Thanks in advance,
Timmie



More information about the Numpy-discussion mailing list