[mod_python] Newbie question: do I need to worry about compilation of modules served directly by mod_python

Graham Dumpleton graham.dumpleton at gmail.com
Sun Jul 27 02:22:05 EDT 2008


2008/7/25 Ling Bao <lingbao at swingvine.com>:
> I'm a newbie to mod_python and the open source community in general.  Here's
> what might seem like a stupid question, but please entertain me : )
>
> I'm building a site and serving its pages with mod_python out of a www
> directory.  I have a bunch of .py files in the www directory for rendering
> the home page, sign in page, etc.  Each of these modules also imports
> packages and modules from other directories.
>
> In the other directories containing the imported modules, I see .pyc files.
> However, in the www directory where the mod_python handler is picking up the
> top-level scripts for handling requests, I don't see any pyc files.  I think
> this is expected because python doesn't auto-compile py files unless they're
> imported by some other module.

A custom built module importer is used by mod_python, where for code
files which are reloadable, no .pyc file is generated nor used if it
existed previously.

> My question is am I suffering any performance impact by letting mod_python
> use py top-level scripts under the www directory instead of manually
> compiling these scripts and having mod_python run the pyc files instead.

No.

> Or  is all this moot because mod_python does auto-reloading and keeps the
> scripts under www in memory (unless the py files are modified in which case
> a reload occurs)?

Pretty well, that is the case.

Note that in Python web application hosting, the network performance,
whether Python optimisations is enabled, or whether .pyc files are
used are never going to be the performance bottleneck, so I wouldn't
particularly waste your time on it. Worry more about things like the
performance of algorithms used by your application and database query
performance.

Graham


More information about the Mod_python mailing list