Speed up your Python programs To speedup your Python program, there's nothing like optimizing or redesigning your algorithms.
In case you think you can't do better, you can always use Psyco: Psyco is a Just-In-Time-like compiler for Python for Intel 80x86-compatible processors. It's very easy to use and provides x2 to x100 instant speed-up.
Download psyco for your Python version (http://psyco.sourceforge.net) unzip and copy the \psyco directory to your Python site-packages directory (should be something like c:\pythonXX\Lib\site-packages\psyco\ under Windows) Then, put this at the beginning of your programs:
import psyco psyco.full() Or even better:
try:
import psyco
psyco.full()
except:
pass
This way, if psyco is installed, your program will run faster. If psyco is not available, your program will run as usual.
(And if psyco is still not enough, you can rewrite the code which is too slow in C or C++ and wrap it with SWIG (http://swig.org).) Note: Do not use Psyco when debugging, profiling or tracing your code. You may get innacurate results and strange behaviours.