is it possible to del an imported module?

Discussion in 'Python' started by dw, Feb 18, 2004.

  1. dw

    dw Guest

    my program has potentially hundreds of small py file that
    each open an
    mdichildframe (just like demo from wxPython). I
    implemented it by
    importing the file before use, but would like it be get
    ridded off
    from memory afterward.

    --
    dody wijaya

    ===========================================================================================
    Akses Internet Prabayar TELKOMNet-Prepaid,
    nominal Rp.10.000- Rp.150.000.
    Dapatkan di Plasa - Plasa TELKOM terdekat (khusus di Jawa Timur)
    ===========================================================================================
    dw, Feb 18, 2004
    #1
    1. Advertising

  2. dw

    Peter Hansen Guest

    dw wrote:
    >
    > my program has potentially hundreds of small py file that
    > each open an
    > mdichildframe (just like demo from wxPython). I
    > implemented it by
    > importing the file before use, but would like it be get
    > ridded off
    > from memory afterward.


    Files are actually imported only *once*, and the resulting module
    is cached in sys.modules for later use. If a second or third
    "import" statement imports the same module, it really just creates
    a new reference to the same module.

    If I were you, I wouldn't worry about the overhead of any of this
    unless you actually observe excessive memory consumption in your
    program. (That is, if it doesn't actually cause trouble, just
    ignore it.)

    -Peter
    Peter Hansen, Feb 18, 2004
    #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. dody suria wijaya

    Get importer module from imported module

    dody suria wijaya, Feb 7, 2005, in forum: Python
    Replies:
    5
    Views:
    384
    dody suria wijaya
    Feb 8, 2005
  2. Ryan
    Replies:
    12
    Views:
    477
    Terry Reedy
    Oct 8, 2009
  3. kj
    Replies:
    9
    Views:
    288
    AK Eric
    Nov 12, 2009
  4. Dun Peal
    Replies:
    10
    Views:
    443
    Chris Rebert
    May 3, 2011
  5. Volker Nicolai
    Replies:
    9
    Views:
    906
    Fabian Pilkowski
    Jul 4, 2005
Loading...

Share This Page