unloading imported modules

François Pinard pinard at iro.umontreal.ca
Sat Jul 20 18:33:58 EDT 2002


[Alex Martelli]

> > > > Is it possible in python intepreter to unload imported modules?
> > > No.

> Use sys.getrefcount(x) to know how many references there are to object x,
> be it a module or any other kind of object.  When the reference count
> of an object drops to 0, the object is freed (at once, or eventually).

So, when the reference count of a module drops to 0, and I get that this
is possible, then the module is unloaded.  Isn't it?  Also, I wonder if
a module coming from an `.so' file be effectively reloaded.  And then, if
the previous copy (the memory area in which the `.so' is paged) gets freed?

-- 
François Pinard   http://www.iro.umontreal.ca/~pinard





More information about the Python-list mailing list