<br><br><div class="gmail_quote">On Wed, Feb 8, 2012 at 4:08 PM, Brett Cannon <span dir="ltr">&lt;<a href="mailto:brett@python.org">brett@python.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br><div class="gmail_quote"><div class="im">On Wed, Feb 8, 2012 at 15:31, Terry Reedy <span dir="ltr">&lt;<a href="mailto:tjreedy@udel.edu" target="_blank">tjreedy@udel.edu</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


<div>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.</div></blockquote><div><br></div></div><div>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.).</div>
</div></blockquote><div><br></div><div>There&#39;s actually only a few things stopping all imports from being lazy.  &quot;from x import y&quot; immediately de-lazies them, after all.  ;-)</div><div><br></div><div>The main two reasons you wouldn&#39;t want imports to *always* be lazy are:</div>
<div><br></div><div>1. Changing sys.path or other parameters between the import statement and the actual import</div><div>2. ImportErrors are likewise deferred until point-of-use, so conditional importing with try/except would break.</div>
</div>