Does Python cache the startup module?

Discussion in 'Python' started by Baz Walter, Jan 7, 2008.

  1. Baz Walter

    Baz Walter Guest

    Hello

    I remember reading somewhere (probably this list) that python may cache the
    module that starts a program (e.g. 'main.py'). 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.

    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?

    TIA
    Baz Walter, Jan 7, 2008
    #1
    1. Advertising

  2. Baz Walter

    Guest

    On Jan 7, 12:30 pm, Baz Walter <> wrote:
    > Hello
    >
    > I remember reading somewhere (probably this list) that python may cache the
    > module that starts a program (e.g. 'main.py'). 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.
    >
    > 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?
    >
    > TIA


    You can run a dir() in the GUI IDLE or the command line IDLE and see
    what's currently "cached", so to speak. In the GUI IDLE, you can
    "flush" it out by going to the Shell menu and choosing Restart Shell.

    It should only display the following after a restart:

    >>> dir()

    ['__builtins__', '__doc__', '__name__']


    HTH

    Mike
    , Jan 7, 2008
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jeff Nokes

    Cache::Cache Stale Segments

    Jeff Nokes, Sep 30, 2003, in forum: Perl
    Replies:
    0
    Views:
    558
    Jeff Nokes
    Sep 30, 2003
  2. Lars Schouw
    Replies:
    4
    Views:
    808
    Lars Schouw
    Oct 28, 2003
  3. The Jetman
    Replies:
    0
    Views:
    419
    The Jetman
    Jul 27, 2004
  4. Replies:
    1
    Views:
    572
  5. Larry
    Replies:
    7
    Views:
    108
    Joe Smith
    Jan 5, 2006
Loading...

Share This Page