speeding up Python script

Lonnie Princehouse finite.automaton at gmail.com
Wed May 18 15:10:12 EDT 2005


Quick tip-
  Try xrange instead of range.  This will use dramatically less memory
if your search space is large, which will speed things up /if/ your
machine is being forced to swap.

Besides that, without seeing the code for your functions, it's hard to
offer more advice.  Your algorithm is necessarily going to take a long
time because you're enumerating all of the possible values of your
functions in a six dimensional space!!   Recoding the whole program in
C would get you maybe an order of magnitude increase for any given
problem size, but it will still get really slow as the size of your
search space increases.

What are function1, function2, and function3?  You might really
consider looking into some numerical methods for optimization if you're
just trying to find the smallest/largest value of ia.




More information about the Python-list mailing list