[SciPy-User] Parallelizing a for loop

Anne Archibald peridot.faceted at gmail.com
Wed Dec 23 17:16:35 EST 2009


2009/12/23 Askey, Scott A Capt USAF AETC AFIT/ENY <Scott.Askey at afit.edu>:
>
> I am looking for a good way to speed the calculation of the of the residuals and and the Jacobian of for fsolve.
>
> For a small problem with 10 elements (420x420) the Jacobians .04 seconds to calculate and the residuals 420x1 take .007 seconds.
> The residual and Jacobian elements are independent and calculated in a for loop.
>
> Is threading or multiprocessing more appropriate.

A first step, if this is possible, would be to eliminate the for loops
using numpy. Since interpreting each python statement takes a fair
number of microseconds, your code will run much faster if you can
rewrite it in terms of array operations. With a little luck it may
also simplify your code.

Anne

> Cheers,
>
> Scott
> _______________________________________________
> SciPy-User mailing list
> SciPy-User at scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>



More information about the SciPy-User mailing list