On 4/12/06, "Martin v. Löwis" <[EMAIL PROTECTED]> 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 <[EMAIL PROTECTED]>

Hi! I'm a .signature virus! copy me into your .signature file to help me spread!
_______________________________________________
Python-3000 mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe: 
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com

Reply via email to