Does Python cache the startup module?

Guilherme Polo ggpolo at
Mon Jan 7 19:47:07 CET 2008

2008/1/7, Baz Walter <bazwal at>:
> Hello
> I remember reading somewhere (probably this list) that python may cache the
> module that starts a program (e.g. '').

Something like mod_python will do caching.

> I'm asking because I have found
> that this can sometimes cause problems when making small edits to the module.
> For instance, in my current module I changed the name of the main gui widget.
> When I ran the program, the program started to leak memory like a sieve. I then
> changed the name back again, and the problem went away. This looks very much
> like some sort of weird caching behaviour to me.

Uhm.. this didn't make much sense. If you say the module is cached,
then supposing you did a minor edit, and then supposing because it is
cached your application wouldn't detect the change, then I don't see
the connection with memory leak.

Bring some concrete proof.

> I've tried deleting the .pyc file and even re-booting, but I can't make the
> problem go away!
> Can anyone confirm that this caching happens? And if so, is it documented
> anywhere?
> --

-- Guilherme H. Polo Goncalves

More information about the Python-list mailing list