[SciPy-User] Speed-up simple function

Emanuele Olivetti emanuele at relativita.com
Mon Jan 10 09:33:13 EST 2011


On 01/10/2011 02:59 PM, g.plantageneto at runbox.com wrote:
> Hi everybody,
>
> I have some functions in python that perform simple computations (they compute the values of some long polynomials). Since I apply them to rather large arrays (10^5 elements) these functions slow down the script quite a bit. Is there a quick and simple way to speed up these functions?
>

Hi,

Could you give us some more details? If the issue is the large number of polynomial
evaluations I believe that it is already fast in numpy. Eg., 10^5 evaluations
of a pretty long polynomial (100 terms):

In [18]: %timeit np.polyval(np.linspace(-1,1,100),np.linspace(0,5,100000))
1 loops, best of 3: 360 ms per loop

Best,

Emanuele





More information about the SciPy-User mailing list