is it possible to del an imported module?

D

dw

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)
===========================================================================================
 
P

Peter Hansen

dw said:
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top