[Python-3000] Draft PEP: Module Initialization and finalization

Thomas Wouters thomas at python.org
Wed Apr 12 20:46:28 CEST 2006


On 4/12/06, "Martin v. Löwis" <martin at v.loewis.de> wrote:
>
> Thomas Wouters wrote:
> > Actually, no, reload() has to remove the module from sys.modules and
> > load it anew.
>
> That's not what reload currently does for Python modules. The module
> object stays the same (so that anybody who imported it will also see
> the reload's effect).
>
> > The reason for this is that any instances of types defined
> > in the module can still live, after the reload, and they would still
> > refer to their old-module-object-referring types. (And, as you said,
> > this is a reason to keep the 'state' in module objects.)
>
> Are you expecting that reload of an extension module will actually
> load the current code from disk? This can't really work: on some
> systems, you can't update the DLL while it is in use; on others,
> it might not be possible to load the same shared library twice.


Well, in the case of Python modules, a reload recreates all classes, so
existing instances remain instances of the old class (and typechecks by name
fail in unexpected ways; you've got to love those "Excected 'Foo' instance,
got 'Foo' instance" errors ;) I guess I was thinking we need to work around
that for C modules as well, but I guess we really don't.

--
Thomas Wouters <thomas at python.org>

Hi! I'm a .signature virus! copy me into your .signature file to help me
spread!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/python-3000/attachments/20060412/bc188f5d/attachment.html 


More information about the Python-3000 mailing list