[Python-ideas] PEP 492 terminology - (native) coroutine objects

Ron Adam ron3200 at gmail.com
Fri May 1 19:03:47 CEST 2015



On 05/01/2015 01:24 AM, Greg Ewing wrote:
> Ron Adam wrote:
>
>> A waiter?
>> or awaiter?
>>
>> As in a-wait-ing an awaiter.
>
> The waiter would be the function executing the await
> operator, not the thing it's operating on.

> In a restaurant, waiters wait on customers. But calling
> an awaitable object a "customer" doesn't seem right
> at all.

Guido has been using awaitable over in python-dev.  Lets see how that works...

In a restaurant, a waiter serves food.  An awaitable is a specific kind of 
waiter..  One that may wait for other waiters to serve their customers 
(table) food before they serve your food, even though your order may have 
happened before another tables order was taken.  Each awaitable only serves 
one table, and never takes orders or serves food to any other table.

In a normal python restaurant without awaitables, each waiter must takes 
your order, and then serve your food, before any other waiter can take an 
order and serve it's customer food.

The consumer is the caller of the expression. We can think of restaurant 
tables as function frames. The "awaiter" keyword here just makes sure an 
awaiter is qualified to serve food in this async restaurant.  We don't want 
the Vikings serving food, do we. ;-)

Of course someone needs to get the tables filled.  That's where the maitre 
d' comes in.  He uses an "async for", or "async with", statement to fill 
all the tables with customers and keeps them happy.

That's not perfect, but I think it gets the general concepts correct and 
makes them easier to think about.  (At least for me.)


Cheers,
    Ron













More information about the Python-ideas mailing list