Re: latest update of PEP 451
Eric Snow <[email protected]> Thu, 26 Sep 2013 18:37:33 -0600
| Newsgroups | gmane.comp.python.import |
|---|---|
| Message-ID | <CALFfu7C=1xnh59mW2bjw1vE9DV68pe_sDRjajxvq_78w20H5aw@mail.gmail.com> |
On Thu, Sep 26, 2013 at 1:15 PM, Brett Cannon <[email protected]> wrote: > On Thu, Sep 26, 2013 at 3:02 PM, Eric Snow <[email protected]> > wrote: >> On Sep 25, 2013 7:05 AM, "Brett Cannon" <[email protected]> wrote: >> > On Wed, Sep 25, 2013 at 1:46 AM, Eric Snow <[email protected]> >> > wrote: > > > [SNIP] >> >> >> .. [lazy_import_concerns] >> >> https://mail.python.org/pipermail/python-dev/2013-August/128129.html >> > >> > >> > I should mention that this PEP will actually improve the situation for >> > lazy loading compared to how it is in Python 3.3 when using >> > __getattribute__. Because import now tries to backfill attributes like >> > __package__ and __loader__, any module that is lazy based on attribute >> > access automatically gets loaded by import itself. But with this PEP we can >> > change import's semantics to not do that with spec-loaded modules and thus >> > loader.exec_module() can insert a lazy module into sys.modules and know that >> > it's attributes won't be touched unless you do a ``from ... import`` on it. >> >> Yeah, I'm mostly focused on addressing concerns. Would a lazy load >> example be worth adding to the PEP? > > > If it you don't think it will detract from the rest of the PEP it wouldn't > hurt. If you want I can write up some rough code to demonstrate how it would > work. Meh. I'll add it if needed, but will hold off otherwise. I don't think it will add that much to the PEP. It's not that different from what you can already do with the loader. -eric