speeding up Python script

James Carroll mrmaple at gmail.com
Wed May 18 17:15:21 EDT 2005


It looks like your algorithm really does iterate over all values for
six variables and do lots of math.. then you can't do any better than
implementing the inner loop in C.  It does look like you have some
functions that are being called that are also in python, and it would
be interesting to see if just one of those was the culprit.  If so,
you might be able to replace just one of those calls with something
faster.

I'm no expert, but I have used swig once or twice, I might be able to
help.  What do you think?

If you are going through all the data just to find a minimum or
something, then you might be able to get away with not visiting all of
the values of all six variables.  Some sort of gradient descent
minimization is probably already out there written in C ready to be
used.

-Jim


On 5/18/05, Grant Edwards <grante at visi.com> wrote:
> On 2005-05-18, Luis P. Mendes <luis_lupe2XXX at netvisaoXXX.pt> wrote:
> 
> > I have a 1000 line python script that takes many hours to
> > finish.  It is running with six inside 'for' loops.
>



More information about the Python-list mailing list