Does python always need to compile ENTIRE program before it c an start to run it???

Ellinghaus, Lance lance.ellinghaus at eds.com
Tue Nov 4 00:39:01 CET 2003


This approach is what I use for CGI programs. This allows me to not have to
have mod_python installed, but does allow me to have fast load times for
these programs. It is true, that the execution time of the CGI is much
larger than any possible load time, but this also affects the CPU load due
to the parsing and compilation phases. This is what really kills Perl CGI
program performance and can cause high CPU loads if many CGI programs are
run. By using the .pyc file as an import, that phase is skipped.

Lance Ellinghaus
EDS - TWAI Operations
Phone: 214-922-5454
Cell: 940-597-4755



-----Original Message-----
From: James Kew [mailto:james.kew at btinternet.com] 
Sent: Monday, November 03, 2003 6:12 PM
To: python-list at python.org
Subject: Re: Does python always need to compile ENTIRE program before it can
start to run it???


"John Roth" <newsgroups at jhrothjr.com> wrote in message
news:vqdamhn2pq1qaf at news.supernews.com...

> I've never
> gotten a satisfactory explanation of why it doesn't save the compiled 
> version of the top level script, but then, I've never really looked 
> into it. It's just curious.

I've always wondered that too. The top-level script _might_ be standard
input or command-line, but it seems to me that it often (usually?) is a .py
which _could_ be stashed into a .pyc.

Taken to extremes, it suggests that top-level scripts should be as small as
possible: an if __name__ == "__main__" delegating immediately to a worker
function imported from a helper module. I'm not sure there's anything
realistic that's code-heavy and short-running enough for it to make much
difference, though...

James


-- 
http://mail.python.org/mailman/listinfo/python-list





More information about the Python-list mailing list