[Python-Dev] reload() et al. (Re: [Import-sig] Re: Proposal for a modified import mechanism.)

M.-A. Lemburg mal@lemburg.com
Thu, 15 Nov 2001 11:04:38 +0100


Just van Rossum wrote:
> 
> Thomas Heller wrote:
> 
> >
> http://groups.google.com/groups?selm=9ss15a%2414snvc%242%40ID-59885.news.dfncis.de
> 
> Nice! Maybe I wouldn't have missed that if hadn't been part of the "IsPython
> really O-O?" thread...
> 
> I think it's worth playing with this stuff more. One improvement I would like to
> try is to update methods just like global functions: that way existing callbacks
> that are bound methods will also be updated.

While it seems like a nice idea to update code which is already in
use, I think that this leads down the wrong track. Sooner or
later you'll end up with a complete mess in memory ;-) And depending
on what code you exchange, this can cause serious problems: e.g.
pickled data could become unusable, parts of the system would 
suddenly stop working because of e.g. a name change in one of the APIs,
etc.

What I'd like much more is some generic way to cleanly *remove*
modules and complete packages which are known to be no longer 
in use. 

A problem I sometimes have with long running processes is that 
they import all sorts of bits and pieces just to process a single
request every now and then. The space taken up by these modules 
is never freed. It would be nice to have an API which allows 
unloading these modules completely. Would be even nicer if this 
would extend to extension modules as well :-) (probably won't 
work though...)

> Other nits:
> func_defaults and func_doc should definitely be updated, I'm not sure about
> func_dict.
> 
> General question: why if func_globals not a writable attribute?

Why should it be ? Just think of the security holes this would
open.

-- 
Marc-Andre Lemburg
CEO eGenix.com Software GmbH
______________________________________________________________________
Consulting & Company:                           http://www.egenix.com/
Python Software:                        http://www.lemburg.com/python/