[Python-Dev] PEP 451 update
Eric Snow
ericsnowcurrently at gmail.com
Wed Oct 30 00:02:49 CET 2013
On Tue, Oct 29, 2013 at 3:32 AM, Nick Coghlan <ncoghlan at gmail.com> wrote:
> On 29 Oct 2013 14:45, "Eric Snow" <ericsnowcurrently at gmail.com> wrote:
>> I'd rather give loaders another optional method:
>> supports_reload(name). Complicating the spec methods signatures (to
>> support passing the old spec through) just for the sake of reload
>> seems less than optimal. I don't see any benefit to exposing the old
>> spec to loader.exec_module().
>
> I do: it lets the loader tell if anything changed from the previous load
> operation, allowing it to make an informed decision on whether or not to
> permit the reload operation or throw an exception.
>
> However, I accept such a check would be better implemented as a separate
> yes/no method, so it makes sense to postpone this aspect to 3.5 at the
> earliest.
With the PEP, loaders are no longer in charge of the module-related
boilerplate. This means that by the time exec_module() gets called,
they won't be able to determine for themselves if it's a reload by
checking sys.modules. That's the point of adding
loader.supports_reload(). (I haven't added that rationale to the PEP
yet).
If it makes a difference to loaders to also look at the previous spec
during supports_reload(), then I think we should add that parameter
now. Otherwise if we add the parameter later it makes it messier.
The signature would now be:
Loader.supports_reload(name, old_spec)
-eric
More information about the Python-Dev
mailing list