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

Thomas Wouters thomas at python.org
Wed Apr 12 11:22:43 CEST 2006


On 4/12/06, "Martin v. Löwis" <martin at v.loewis.de> wrote:
>
> Tim Peters quoted Guido:
> > - when reload() is used on an extension
>
> This is trickier: I guess reload should invoke the finalize function,
> discard the memory for the state, and then invoke the initialize
> function again, which will allocate a new state block.


Actually, no, reload() has to remove the module from sys.modules and load it
anew. 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.)

This raises the question whether modules should be able to
> participate in cyclic GC...


Don't they already? They have a traverse proc, just not a clear proc.

--
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/44ffd02b/attachment.html 


More information about the Python-3000 mailing list