<div dir="ltr">I'm fairly novice, so I could be way off base here, but it seems like the inevitable conclusion to this problem is something like JIT compilation, right? (admittedly, I know very little about JIT compilation)<br><br>Python seems to be accumulating a lot of different approaches to achieving very similar things: asynchronous and/or lazy execution. We have generators, futures, asyncio, async/await, and probably more that I'm not thinking of. It seems like it should be possible for the interpreter to determine when an expression absolutely *must* be evaluated in many cases. If I write:<br><br><font face="monospace, monospace">>>> log.debug("data = %s", some_expensive_function())</font><br><br>Then it should be possible for python to put off evaluating that function or even building a full argument tuple if the log level is higher than debug.<br><br>I know code with side-effects, especially I/O related side-effects would be difficult or impossible to manage within that context (the interpreter wouldn't be able to know that a write to a file has to occur before a read from that file for instance. Maybe it would make more sense to mark such side-effects to tell the interpreter "you must evaluate all deferred expressions before executing this because it changes stuff that Python can't keep track of". instead of marking code that the compiler can optimize.<br><br>My gut reaction says this is not the answer because it emphasizes optimization over correct behavior, but I wanted to share the thought.<br><br><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Feb 17, 2017 at 3:30 PM, Joseph Hackman <span dir="ltr"><<a href="mailto:josephhackman@gmail.com" target="_blank">josephhackman@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto"><div>Abe-</div><div id="m_-1774925914347827412AppleMailSignature"><br></div><div id="m_-1774925914347827412AppleMailSignature">You are correct. However I think it may still be salvageable.</div><div id="m_-1774925914347827412AppleMailSignature"><br></div><div id="m_-1774925914347827412AppleMailSignature">In your code example, you could be either making a dict with a key of 1, or a set of a delayed object. But there's no reason to build a set of a delayed object because hashing it would immediately un-delay. </div><div id="m_-1774925914347827412AppleMailSignature"><br></div><div id="m_-1774925914347827412AppleMailSignature">Similarly, I am not sure delayed should be allowed inside of function headers. </div><div id="m_-1774925914347827412AppleMailSignature"><br></div><div id="m_-1774925914347827412AppleMailSignature">So we could say that dictionary keys and sets shouldn't be allowed to use the delayed keyword. Same with function headers. Are there any other collisions?</div><span class="HOEnZb"><font color="#888888"><div id="m_-1774925914347827412AppleMailSignature"><br>-Joseph</div></font></span><div><div class="h5"><div><br>On Feb 17, 2017, at 3:41 PM, Abe Dillon <<a href="mailto:abedillon@gmail.com" target="_blank">abedillon@gmail.com</a>> wrote:<br><br></div><blockquote type="cite"><div><div dir="ltr"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span style="font-size:12.8px">Couldn't the same thing be true of delayed if it is always followed by a colon?</span></blockquote><div><br>No. Because there are other reasons you'd follow the variable `delayed` with a colon:<br><br>>>> delayed = 1</div><div>>>> d = {delayed: "oops!"}</div><div><br></div><div>My earlier proposal (using unpacking syntax) doesn't work for the same reason.  </div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Feb 17, 2017 at 2:31 PM, Joseph Hackman <span dir="ltr"><<a href="mailto:josephhackman@gmail.com" target="_blank">josephhackman@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto"><div>Couldn't the same thing be true of delayed if it is always followed by a colon?</div><div id="m_-1774925914347827412m_2786872494577044548AppleMailSignature"><br></div><div id="m_-1774925914347827412m_2786872494577044548AppleMailSignature">I.e. </div><div id="m_-1774925914347827412m_2786872494577044548AppleMailSignature">delayed=1</div><div id="m_-1774925914347827412m_2786872494577044548AppleMailSignature">x= delayed: slow_function()</div><div id="m_-1774925914347827412m_2786872494577044548AppleMailSignature">print(delayed) # prints 1</div><span class="m_-1774925914347827412HOEnZb"><font color="#888888"><div id="m_-1774925914347827412m_2786872494577044548AppleMailSignature"><br></div><div id="m_-1774925914347827412m_2786872494577044548AppleMailSignature">-Joseph</div></font></span><div><div class="m_-1774925914347827412h5"><div><br>On Feb 17, 2017, at 2:39 PM, Mark E. Haase <<a href="mailto:mehaase@gmail.com" target="_blank">mehaase@gmail.com</a>> wrote:<br><br></div><blockquote type="cite"><div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Fri, Feb 17, 2017 at 1:55 PM, Joshua Morton <span dir="ltr"><<a href="mailto:joshua.morton13@gmail.com" target="_blank">joshua.morton13@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">but I'm wondering how common async and await were when that was proposed and accepted?</blockquote></div><div class="gmail_extra"><br></div><div class="gmail_extra">Actually, "async" and "await" are backwards compatible due to a clever tokenizer hack. The "async" keyword may only appear in a few places (e.g. async def), and it is treated as a name anywhere else.The "await" keyword may only appear inside an "async def" and is treated as a name everywhere else. Therefore...<br></div></div><div class="gmail_extra"><br></div><div class="gmail_extra">    >>> async = 1</div><div class="gmail_extra">    >>> await = 1</div><div class="gmail_extra"><br></div><div class="gmail_extra">...these are both valid in Python 3.5. This example is helpful when proposing new keywords.</div><div class="gmail_extra"><br></div><div class="gmail_extra">More info: <a href="https://www.python.org/dev/peps/pep-0492/#transition-plan" target="_blank">https://www.python.org/d<wbr>ev/peps/pep-0492/#transition-p<wbr>lan</a></div><div class="gmail_extra"><br></div><div class="gmail_extra"><br></div></div>
</div></blockquote></div></div><span><blockquote type="cite"><div><span>______________________________<wbr>_________________</span><br><span>Python-ideas mailing list</span><br><span><a href="mailto:Python-ideas@python.org" target="_blank">Python-ideas@python.org</a></span><br><span><a href="https://mail.python.org/mailman/listinfo/python-ideas" target="_blank">https://mail.python.org/mailma<wbr>n/listinfo/python-ideas</a></span><br><span>Code of Conduct: <a href="http://python.org/psf/codeofconduct/" target="_blank">http://python.org/psf/codeofco<wbr>nduct/</a></span></div></blockquote></span></div><br>______________________________<wbr>_________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org" target="_blank">Python-ideas@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-ideas" rel="noreferrer" target="_blank">https://mail.python.org/mailma<wbr>n/listinfo/python-ideas</a><br>
Code of Conduct: <a href="http://python.org/psf/codeofconduct/" rel="noreferrer" target="_blank">http://python.org/psf/codeofco<wbr>nduct/</a><br></blockquote></div><br></div>
</div></blockquote></div></div></div></blockquote></div><br></div>