<div dir="ltr">This comes from a bit of a misunderstanding of how an interpreter figures out what needs to be compiled. Most (all?) JIT compilers run code in an interpreted manner, and then compile subsections down to efficient machine code when they notice that the same code path is taken repeatedly, so in pypy something like <div><br></div><div> x = 0</div><div> for i in range(100000):</div><div> x += 1</div><div><br></div><div>would, get, after 10-20 runs through the loop, turned into assembly that looked like what you'd write in pure C, instead of the very indirection and pointer heavy code that such a loop would be if you could take it and convert it to cpython actually executes, for example. So the "hot" code is still run.</div><div><br></div><div>All that said, this is a bit of an off topic discussion and probably shouldn't be on list.</div><div><br></div><div>What you really do want is functional purity, which is a different concept and one that python as a language can't easily provide no matter what.</div><div><br></div><div>--Josh</div></div><br><div class="gmail_quote"><div dir="ltr">On Mon, Feb 20, 2017 at 7:53 PM Abe Dillon <<a href="mailto:abedillon@gmail.com">abedillon@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class="gmail_msg"><span style="color:rgb(80,0,80);font-size:12.8px" class="gmail_msg">On Fri, Feb 17, 2017, Steven D'Aprano wrote:<br class="gmail_msg"></span><blockquote class="gmail_quote gmail_msg" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span style="font-size:12.8px" class="gmail_msg">JIT compilation delays *compiling* the code to run-time. This is a</span><br style="font-size:12.8px" class="gmail_msg"><span style="font-size:12.8px" class="gmail_msg">proposal for delaying *running* the code until such time as some other</span><br style="font-size:12.8px" class="gmail_msg"><span style="font-size:12.8px" class="gmail_msg">piece of code actually needs the result.</span></blockquote></div><div dir="ltr" class="gmail_msg"><div class="gmail_msg"><br class="gmail_msg">My thought was that if a compiler is capable of determining what needs to be compiled just in time, then an interpreter might be able to determine what expressions need to be evaluated just when their results are actually used.<br class="gmail_msg"><br class="gmail_msg">So if you had code that looked like:<br class="gmail_msg"><br class="gmail_msg">>>> log.debug("data: %s", expensive())<br class="gmail_msg"><br class="gmail_msg">The interpreter could skip evaluating the expensive function if the result is never used. It would only evaluate it "just in time". This would almost certainly require just in time compilation as well, otherwise the byte code that calls the "log.debug" function would be unaware of the byte code that implements the function.<br class="gmail_msg"><br class="gmail_msg">This is probably a pipe-dream, though; because the interpreter would have to be aware of side effects.<br class="gmail_msg"><br class="gmail_msg"><br class="gmail_msg"></div></div><div class="gmail_extra gmail_msg"><br class="gmail_msg"><div class="gmail_quote gmail_msg">On Mon, Feb 20, 2017 at 5:18 AM, <span dir="ltr" class="gmail_msg"><<a href="mailto:tritium-list@sdamon.com" class="gmail_msg" target="_blank">tritium-list@sdamon.com</a>></span> wrote:<br class="gmail_msg"><blockquote class="gmail_quote gmail_msg" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="gmail_msg"><br class="gmail_msg">
<br class="gmail_msg">
> -----Original Message-----<br class="gmail_msg">
> From: Python-ideas [mailto:<a href="mailto:python-ideas-bounces%2Btritium-" class="gmail_msg" target="_blank">python-ideas-bounces+tritium-</a><br class="gmail_msg">
> list=<a href="mailto:sdamon.com@python.org" class="gmail_msg" target="_blank">sdamon.com@python.org</a>] On Behalf Of Michel Desmoulin<br class="gmail_msg">
> Sent: Monday, February 20, 2017 3:30 AM<br class="gmail_msg">
> To: <a href="mailto:python-ideas@python.org" class="gmail_msg" target="_blank">python-ideas@python.org</a><br class="gmail_msg">
> Subject: Re: [Python-ideas] Delayed Execution via Keyword<br class="gmail_msg">
><br class="gmail_msg">
> I wrote a blog post about this, and someone asked me if it meant<br class="gmail_msg">
> allowing lazy imports to make optional imports easier.<br class="gmail_msg">
><br class="gmail_msg">
> Someting like:<br class="gmail_msg">
><br class="gmail_msg">
> lazy import foo<br class="gmail_msg">
> lazy from foo import bar<br class="gmail_msg">
><br class="gmail_msg">
> So now if I don't use the imports, the module is not loaded, which could<br class="gmail_msg">
> also significantly speed up applications starting time with a lot of<br class="gmail_msg">
> imports.<br class="gmail_msg">
<br class="gmail_msg">
</span>Would that not also make a failure to import an error at the time of<br class="gmail_msg">
executing the imported piece of code rather than at the place of import?<br class="gmail_msg">
And how would optional imports work if they are not loaded until use? Right<br class="gmail_msg">
now, optional imports are done by wrapping the import statement in a<br class="gmail_msg">
try/except, would you not need to do that handling everywhere the imported<br class="gmail_msg">
object is used instead?<br class="gmail_msg">
<br class="gmail_msg">
(I haven't been following the entire thread, and I don't know if this is a<br class="gmail_msg">
forest/tress argument)<br class="gmail_msg">
<div class="m_4963579814170615314HOEnZb gmail_msg"><div class="m_4963579814170615314h5 gmail_msg"><br class="gmail_msg">
> _______________________________________________<br class="gmail_msg">
> Python-ideas mailing list<br class="gmail_msg">
> <a href="mailto:Python-ideas@python.org" class="gmail_msg" target="_blank">Python-ideas@python.org</a><br class="gmail_msg">
> <a href="https://mail.python.org/mailman/listinfo/python-ideas" rel="noreferrer" class="gmail_msg" target="_blank">https://mail.python.org/mailman/listinfo/python-ideas</a><br class="gmail_msg">
> Code of Conduct: <a href="http://python.org/psf/codeofconduct/" rel="noreferrer" class="gmail_msg" target="_blank">http://python.org/psf/codeofconduct/</a><br class="gmail_msg">
<br class="gmail_msg">
_______________________________________________<br class="gmail_msg">
Python-ideas mailing list<br class="gmail_msg">
<a href="mailto:Python-ideas@python.org" class="gmail_msg" target="_blank">Python-ideas@python.org</a><br class="gmail_msg">
<a href="https://mail.python.org/mailman/listinfo/python-ideas" rel="noreferrer" class="gmail_msg" target="_blank">https://mail.python.org/mailman/listinfo/python-ideas</a><br class="gmail_msg">
Code of Conduct: <a href="http://python.org/psf/codeofconduct/" rel="noreferrer" class="gmail_msg" target="_blank">http://python.org/psf/codeofconduct/</a><br class="gmail_msg">
</div></div></blockquote></div><br class="gmail_msg"></div>
_______________________________________________<br class="gmail_msg">
Python-ideas mailing list<br class="gmail_msg">
<a href="mailto:Python-ideas@python.org" class="gmail_msg" target="_blank">Python-ideas@python.org</a><br class="gmail_msg">
<a href="https://mail.python.org/mailman/listinfo/python-ideas" rel="noreferrer" class="gmail_msg" target="_blank">https://mail.python.org/mailman/listinfo/python-ideas</a><br class="gmail_msg">
Code of Conduct: <a href="http://python.org/psf/codeofconduct/" rel="noreferrer" class="gmail_msg" target="_blank">http://python.org/psf/codeofconduct/</a></blockquote></div>