<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Apr 30, 2015 at 11:41 AM, Jim J. Jewett <span dir="ltr"><<a href="mailto:jimjjewett@gmail.com" target="_blank">jimjjewett@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"><br>
On Wed Apr 29 20:06:23 CEST 2015,Yury Selivanov replied:<br>
<span class=""><br>
>> As best I can guess, the difference seems to be that a "normal"<br>
>> generator is using yield primarily to say:<br>
<br>
>>      "I'm not done; I have more values when you want them",<br></span></blockquote><div><br>This seems so vague as to be useless to me. When using generators to 
implement iterators, "yield" very specifically means "here is the next 
value in the sequence I'm generating". (And to indicate there are no more values you have to use "return".)<br> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="">
>> but an asynchronous (PEP492) coroutine is primarily saying:<br>
<br>
>>      "This might take a while, go ahead and do something else meanwhile."<br>
<br>
> Correct.<br></span></blockquote><div><br></div><div>Actually that's not even wrong. When using generators as coroutines, PEP 342 style, "yield" means "I am blocked waiting for a result that the I/O multiplexer is eventually going to produce". The argument to yield tells the multiplexer what the coroutine is waiting for, and it puts the generator stack frame on an appropriate queue. When the multiplexer has obtained the requested result it resumes the coroutine by using send() with that value, which resumes the coroutine/generator frame, making that value the return value from yield.<br><br></div><div>Read Greg Ewing's tutorial for more color: <a href="http://www.cosc.canterbury.ac.nz/greg.ewing/python/yield-from/yield_from.html">http://www.cosc.canterbury.ac.nz/greg.ewing/python/yield-from/yield_from.html</a><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="">
</span>Then I strongly request a more specific name than coroutine.<br></blockquote><div><br></div><div>No, this is the name we've been using since PEP 342 and it's still the same concept.<br><br></div></div>-- <br><div class="gmail_signature">--Guido van Rossum (<a href="http://python.org/~guido" target="_blank">python.org/~guido</a>)</div>
</div></div>