[Python-Dev] PEP 451 update
Eric Snow
ericsnowcurrently at gmail.com
Tue Oct 29 05:56:37 CET 2013
On Sun, Oct 27, 2013 at 4:41 PM, PJ Eby <pje at telecommunity.com> wrote:
> I'm talking about userspace code that implements lazy importing
> features, like the lazyModule() function in this module:
>
> http://svn.eby-sarna.com/Importing/peak/util/imports.py?view=markup
>
> Specifically, I'm trying to get an idea of how much that code will
> need to change under the PEP (and apparently under importlib in
> general).
Depending on the outcome of issue19413, you shouldn't have to change
anything. PEP 451 is aiming for strict backward compatibility.
> Honestly, I'm finding all this stuff *really* confusing, which is kind
> of worrying. I mean, I gather I'm one of the handful of people who
> really understood how importing *used to work*, and I'm having a lot
> of trouble wrapping my brain around the new world.
>
> (Granted, I think that may be because I understand how a lot of old
> corner cases work,
Like Nick, I would love more tests that cover these corner cases. It
would have saved us (Brett especially) a lot of headache. At the
least any description you can offer would be great.
> but what's bugging me is that I no longer
> understand how those old corners work under the new regime, nor do I
> feel I understand what the *new* corners will be. This may also just
> be communication problems, and the fact that it's been months since I
> really walked through importlib line by line, and have never really
> walked through it (or PEP 451) quite as thoroughly as I have import.c.
> I also seem to be having trouble grokking why the motivating use
> cases for PEP 451 can't be solved by just providing people with good
> base classes to use for writing loaders -- i.e., I don't get why the
> core protocol has to change to address the use case of writing loaders
> more easily. The new protocol seems way more complex than PEP 302,
What new protocol specifically? Finder.find_module() now returns a
module spec instead of a loader. Loader.exec_module() gets used now
rather than load_module(). Loaders don't have to worry about all the
boilerplate stuff anymore (managing sys.modules and import-related
module attributes). From my perspective PEP 451 is simplifying
protocols.
-eric
> and ISTM the complexity could just be pushed off to the loader side of
> the protocol without creating more interdependency between importlib
> and the loaders.)
More information about the Python-Dev
mailing list