<br><br><div class="gmail_quote">On Tue, Feb 7, 2012 at 16:51, PJ Eby <span dir="ltr">&lt;<a href="mailto:pje@telecommunity.com">pje@telecommunity.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div class="gmail_quote"><div class="im">On Tue, Feb 7, 2012 at 3:07 PM, Brett Cannon <span dir="ltr">&lt;<a href="mailto:brett@python.org" target="_blank">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">


<div>So, if there is going to be some baseline performance target I need to hit to make people happy I would prefer to know what that (real-world) benchmark is and what the performance target is going to be on a non-debug build. And if people are not worried about the performance then I&#39;m happy with that as well. =)</div>


</blockquote><div><br></div></div><div>One thing I&#39;m a bit worried about is repeated imports, especially ones that are inside frequently-called functions.  In today&#39;s versions of Python, this is a performance win for &quot;command-line tool platform&quot; systems like Mercurial and PEAK, where you want to delay importing as long as possible, in case the code that needs the import is never called at all...  but, if it *is* used, you may still need to use it a lot of times.</div>


<div><br></div><div>When writing that kind of code, I usually just unconditionally import inside the function, because the C code check for an already-imported module is faster than the Python &quot;if&quot; statement I&#39;d have to clutter up my otherwise-clean function with.</div>


<div><br></div><div>So, in addition to the things other people have mentioned as performance targets, I&#39;d like to keep the slowdown factor low for this type of scenario as well.  Specifically, the slowdown shouldn&#39;t be so much as to motivate lazy importers like Mercurial and PEAK to need to rewrite in-function imports to do the already-imported check ourselves.  ;-)</div>


<div><br></div><div>(Disclaimer: I haven&#39;t actually seen Mercurial&#39;s delayed/dynamic import code, so I can&#39;t say for 100% sure if they&#39;d be affected the same way.)</div></div>
</blockquote></div><br><div>IOW you want the sys.modules case fast, which I will never be able to match compared to C code since that is pure execution with no I/O.</div>