[Python-Dev] PEP 420 - dynamic path computation is missing rationale

PJ Eby pje at telecommunity.com
Wed May 23 03:49:16 CEST 2012


On Tue, May 22, 2012 at 8:40 PM, Eric V. Smith <eric at trueblade.com> wrote:

> On 5/22/2012 2:37 PM, Guido van Rossum wrote:
> > Okay, I've been convinced that keeping the dynamic path feature is a
> > good idea. I am really looking forward to seeing the rationale added
> > to the PEP -- that's pretty much the last thing on my list that made
> > me hesitate. I'll leave the details of exactly how the parent path is
> > referenced up to the implementation team (several good points were
> > made), as long as the restriction that sys.path must be modified in
> > place is lifted.
>
> I've updated the PEP. Let me know how it looks.
>

My name is misspelled in it, but otherwise it looks fine.  ;-)

I have not updated the implementation yet. I'm not exactly sure how I'm
> going to convert from a path list of unknown origin to ('sys', 'path')
> or ('foo', '__path__'). I'll look at it later tonight to see if it's
> possible. I'm hoping it doesn't require major surgery to
> importlib._bootstrap.
>

It shouldn't - all you should need is to use
getattr(sys.modules[self.modname], self.attr) instead of referencing a
parent path object directly.

(The more interesting thing is what to do if the parent module goes away,
due to somebody deleting the module out of sys.modules.  The simplest thing
to do would probably be to just keep using the cached value in that case.)

Ah crap, I just thought of something - what happens if you reload() a
namespace package?  Probably nothing, but should we specify what sort of
nothing?  ;-)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20120522/e466cc51/attachment.html>


More information about the Python-Dev mailing list