You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
PEP 492 introduces a few new ABCs: Awaitable, Coroutine, AsyncIterable, AsyncIterator. PEP 484 lists three of these: Awaitable, AsyncIterable, AsyncIterator. What happened to Coroutine? A Coroutine is an Awaitable that also supports send(), throw() and close().
It seems a simple oversight. Let's fix it before 3.5.3 comes out.
@1st1 do you remember any of this? Do you recall a reason to leave out Coroutine?
I just realized a super neat thing would be also being able to specify the return type of co_method parameter like Callable If it were possible something like:
@gvanrossum
I see that you have assigned this issue to yourself, but if you don't mind, I would like to do this (in python/typing and in python/peps). Just a small clarification: should order of type variables be the same as for Generator? So that:
I'm fine with you doing this, but I had thought that Coroutine would have
only one parameter (the return type). I guess this means we'll need to look
at some example code to see how it would be used.
In principle a normal coroutine defined with async def has a trivial .send() method that only accepts None and raises StopIteration. However, one could make a coroutine "manually" by instantiating a non-abstract subclass of collections.abc.Coroutine. Such "manually created" coroutine could have a non-trivial .send() method. But I agree with you that this use case is probably rare. I do not have a preference here. @1st1 what do you think?
@gvanrossum Yet another option would be to make Coroutie a special form. So that Coroutine[[X, Y], Z] is essentially equivalent to Callable [[X, Y], Awaitable[Z].
Activity
1st1 commentedon Jul 22, 2016
No, I suspect it was left out by mistake.
gvanrossum commentedon Jul 22, 2016
thehesiod commentedon Oct 24, 2016
it would be neat if we could specify the parameters to the coroutine as well...something like:
I just realized a super neat thing would be also being able to specify the return type of
co_methodparameter like Callable If it were possible something like:ilevkivskyi commentedon Oct 29, 2016
@gvanrossum
I see that you have assigned this issue to yourself, but if you don't mind, I would like to do this (in
python/typingand inpython/peps). Just a small clarification: should order of type variables be the same as forGenerator? So that:gvanrossum commentedon Oct 29, 2016
ilevkivskyi commentedon Oct 29, 2016
In principle a normal coroutine defined with
async defhas a trivial.send()method that only acceptsNoneand raisesStopIteration. However, one could make a coroutine "manually" by instantiating a non-abstract subclass ofcollections.abc.Coroutine. Such "manually created" coroutine could have a non-trivial.send()method. But I agree with you that this use case is probably rare. I do not have a preference here. @1st1 what do you think?ilevkivskyi commentedon Oct 29, 2016
@gvanrossum Yet another option would be to make
Coroutiea special form. So thatCoroutine[[X, Y], Z]is essentially equivalent toCallable [[X, Y], Awaitable[Z].gvanrossum commentedon Oct 29, 2016
Oh, no! I think after all it should indeed mimic Generator.