[Python-Dev] PEP: Lazy module imports and post import hook
glyph at divmod.com
glyph at divmod.com
Wed Jan 9 04:50:03 CET 2008
On 01:09 am, andrew-pythondev at puzzling.org wrote:
>Neal Becker wrote:
>>Christian Heimes wrote:
>>
>> > I've attached the first public draft of my first PEP. A working
>>patch
>> > against the py3k branch is available at
>>http://bugs.python.org/issue1576
>> >
>> > Christian
>>
>>Note also that mercurial has demandimport
>>http://www.selenic.com/mercurial/wiki/
>
>And that bzr has lazy_import (inspired by mercurial's demandimport):
and very recently, I implemented similar functionality myself (though it
isn't in use in Twisted yet):
http://codebrowse.launchpad.net/~glyph/+junk/pyexport/files
Something that I notice about every other implementation of this
functionality is that they're all in Python. But the proposed
implementation here is written in C, and therefore more prone to
crashing bugs. Looking at the roundup log, I can see that several
refcounting bugs have already been found and fixed. Perhaps the post-
import hooks, being a modification to the import mechanism itself, needs
to be in C, but given that lazy imports *have* been implemented before
without using C code (and without post import hooks), I can't see why
they need to be in the same PEP.
Also, as is my custom, I'd like to suggest that, rather than designing
something new, one of the third-party implementations be adopted (or at
least its interface) since these have been demonstrated to work in real
application code already. Happily, I can escape the charge of bias this
time since I don't think my own implementation should be taken seriously
in this case :).
More information about the Python-Dev
mailing list