On Wed, Feb 8, 2012 at 20:28, PJ Eby <p...@telecommunity.com> wrote:

>
>
> On Wed, Feb 8, 2012 at 4:08 PM, Brett Cannon <br...@python.org> wrote:
>
>>
>> On Wed, Feb 8, 2012 at 15:31, Terry Reedy <tjre...@udel.edu> wrote:
>>
>>> For top-level imports, unless *all* are made lazy, then there *must* be
>>> some indication in the code of whether to make it lazy or not.
>>>
>>
>> Not true; importlib would make it dead-simple to whitelist what modules
>> to make lazy (e.g. your app code lazy but all stdlib stuff not, etc.).
>>
>
> There's actually only a few things stopping all imports from being lazy.
>  "from x import y" immediately de-lazies them, after all.  ;-)
>
> The main two reasons you wouldn't want imports to *always* be lazy are:
>
> 1. Changing sys.path or other parameters between the import statement and
> the actual import
> 2. ImportErrors are likewise deferred until point-of-use, so conditional
> importing with try/except would break.
>

This actually depends on the type of ImportError. My current solution
actually would trigger an ImportError at the import statement if no finder
could locate the module. But if some ImportError was raised because of some
other issue during load then that would come up at first use.
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to