[Python-ideas] Proposal for an enhanced reload mechanism

Peter Ingebretson pingebre at yahoo.com
Tue Oct 19 22:25:49 CEST 2010

--- On Tue, 10/19/10, Chris Kaynor <ckaynor at zindagigames.com> wrote:
This is a proposal (pre-PEP?) for an enhanced reloading mechanism especially designed for iterative development:


The basic plan is to use the existing cycle-detecting GC to remap references from objects in the old module to equivalent objects in the new module.

What happens if you change the __init__ or __new__ methods of an object or if you change a class's metaclass? It seems like those types of changes would be impossible to propagate to existing objects, and without propagating them any changes to existing objects may (are likely?) to break the object.Yes, this is a limitation of the approach.  More generally, any logic that has already runand would execute differently with the reloaded module has the potential to break things.
Even with this limitation I think the approach is still valuable.  I spend far less time modifying__new__ methods and metaclasses than I spend changing the implementation and API ofother class- and module-level methods.
The issue of old instances not having members that are added in a new __init__ isproblematic, but there are several workarounds such as temporarily wrapping the newmember in a property, or potentially the @reloadable decorator alluded to in the doc.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20101019/9947798e/attachment.html>

More information about the Python-ideas mailing list