[Python-ideas] Async API: some code to review

Guido van Rossum guido at python.org
Wed Oct 31 22:51:47 CET 2012


On Wed, Oct 31, 2012 at 2:31 PM, Steve Dower <Steve.Dower at microsoft.com> wrote:
> Guido van Rossum wrote:
>> Just get with the program and use yield-from exclusively.
>
> I didn't realise there was a "program" here, just a discussion about an API design.

Sorry, I left off a smiley. :-)

> I've already raised my concerns with using yield from exclusively, but since the performance argument trumps all of those then there is little more I can contribute.

What about the usability argument? Don't you think users will be
confused by the need to use yield from some times and just yield other
times? Yes, they may be able to tell by looking up the definition and
checking how it is decorated, but that doesn't really help.

> When a final design begins to stabilise, I will see how I can make use of it in my own code. Until then, I'll continue using Futures, which are ideal for my current needs. I won't be forcing 'yield from' onto my users until its usage is clear and I can provide them with suitable guidance.

Understood. What exactly is it that makes Futures so ideal for your
current needs? Is it integration with threads?

Another tack: could you make use of tulip/polling.py? That doesn't use
generators of any form; it is meant as an integration point with other
styles of async programming (although I am not claiming that it is any
good in its current form -- this too is just a strawman to shoot
down).

-- 
--Guido van Rossum (python.org/~guido)



More information about the Python-ideas mailing list