[Python-Dev] requirements for moving __import__ over to importlib?
Brett Cannon
brett at python.org
Wed Feb 8 21:16:54 CET 2012
On Wed, Feb 8, 2012 at 14:57, Terry Reedy <tjreedy at udel.edu> wrote:
> On 2/8/2012 11:13 AM, Brett Cannon wrote:
>
>> On Tue, Feb 7, 2012 at 22:47, Nick Coghlan <ncoghlan at gmail.com
>>
>
> I'm not sure such an addition would help much with the base
>> interpreter start up time though - most of the modules we bring in are
>> because we're actually using them for some reason.
>>
>
> It wouldn't. This would be for third-parties only.
>>
>
> such as hg. That is what I had in mind.
>
> Would the following work? Treat a function as a 'loop' in that it may be
> executed repeatedly. Treat 'import x' in a function as what it is, an
> __import__ call plus a local assignment. Apply a version of the usual
> optimization: put a sys.modules-based lazy import outside of the function
> (at the top of the module?) and leave the local assignment "x =
> sys.modules['x']" in the function. Change sys.modules.__delattr__ to
> replace a module with a dummy, so the function will still work after a
> deletion, as it does now.
Probably, but I would hate to force people to code in a specific way for it
to work.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20120208/cba4180f/attachment.html>
More information about the Python-Dev
mailing list