Keeping Python loaded
Matt Gerrans
mgerrans at ix.netcom.com
Tue Nov 27 04:16:52 EST 2001
This sounds like the slant I'm after. That is, I want more than disk cache
and paging tricks, I want the Python engine initialized and running, so it
doesn't have to do that for every script. The Ant make tool for Java (which
doesn't keep re-loading the java compiler for each separate file, as a normal
make file does), got me going on this idea and I thought it would be handy for
extending my laptop's battery life and improve the performance (eliminate the
load time) of Python scripts in general.
Where do I find mod_python and mod_snake? I searched in my Python directory
to no avail. Are they a part of Apache? Or Zope?
One simple trick I was considering was to write a little Tkinter or wxPython
UI that hangs out (keeping the engine running at all times) and just lets me
name a script; it could then simply import it and call main(). Yes, this
assumes there is a main(); I always have the "if __name__ == "__main__":
main()" line at the end of my scripts, so they can all have the same entry
point and can run stand-alone or be imported. This is not a very general
solution, of course...
- mfg
Martin von Loewis <loewis at informatik.hu-berlin.de> wrote in message
news:j4wv0go1h6.fsf at informatik.hu-berlin.de...
> "Matt Gerrans" <mgerrans at ix.netcom.com> writes:
>
> > Is there some existing facility for keeping Python running in memory
> > at all times, ready to execute scripts, rather than having it load
> > each time a script runs? I think I can figure out a way to do this,
> > but I wanted to check first and see if a clever solution (probably
> > better than what I'm brewing) already exists...
>
> There are a number of specialized solutions, like mod_python or
> mod_snake for Apache, or like Zope. Likewise, the CGIHTTPServer.py
> only forks, instead of exec'ing.
>
> The tricky part is how to tell Python to load and execute another
> script. If that is solved, execfile may be all you need.
>
> Regards,
> Martin
More information about the Python-list
mailing list