[Tutor] how to seed up?
alan.gauld at btinternet.com
Sat May 19 19:50:02 CEST 2007
<emilia12 at mail.bg> wrote
> when i have many modules in my script (eg. 'import pylab,
> os, sys'), python loads them very slow ...
You could try putting all the imports into a single module
and them importing that module. The new imported module
should be compiled into Python byte code the first time
you import it which might be faster on subsequent runs
- I've never tried this so I'm interested in the results!
> so is there a way to run same script many times (with small
> changes in the code), without reloading/parsing all modules
> each time ?
If you split your code into modules and import them at
the Python prompt you can sometimes develop code
in one module while avoiding imports of the rest, but
its not 100% effective.
> and 2nd question - in case of CGI script - is there a way to
> recall faster already loaded/called script?
There are lots of ways around this, including
FastCGI, mod_python, one of the many Python
web frameworks. Look at this page for lots of
Author of the Learn to Program web site
More information about the Tutor