[Tutor] how to seed up?

Andreas Kostyrka andreas at kostyrka.org
Sat May 19 20:53:14 CEST 2007


Check the permissions, python does not emit any warnings if it cannot write the pyc files

Andreas

-- Ursprüngl. Mitteil. --
Betreff:	Re: [Tutor] how to seed up?
Von:	"Alan Gauld" <alan.gauld at btinternet.com>
Datum:		19.05.2007 17:53

<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 
options:

http://wiki.python.org/moin/WebFrameworks

HTH,

-- 
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld

_______________________________________________
Tutor maillist  -  Tutor at python.org
http://mail.python.org/mailman/listinfo/tutor



More information about the Tutor mailing list