This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author scoder
Recipients asvetlov, gvanrossum, ncoghlan, python-dev, scoder, vstinner, yselivanov
Date 2015-05-28.04:18:30
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <55669715.5050207@behnel.de>
In-reply-to <1432785281.63.0.593517313764.issue24017@psf.upfronthosting.co.za>
Content
> It *is* correct, see PEP 492.  Awaitable is either a coroutine *or* an object with an __await__ method.

"coroutine", yes. But "Coroutine"? Shouldn't the Coroutine ABC then require
"__await__" to be implemented? Maybe even by inheriting from Awaitable?

> Just implement tp_await/__await__ for coroutine-like objects coming from C-API or Cython.

Sure, that's how it's done. (Specifically, Coroutine is not an
Iterable/Iterator, but its __await__() returns a thin Iterator that simply
calls into the Generator code. A bit annoying and slowish, but that's what
it takes.)

I was just wondering how Cython should compile Python code that makes use
of this decorator. The Coroutine and Generator types are separated in
Cython now, and I think that's actually the right thing to do. This
types.coroutine() decorator and special casing in CPython's code base gets
a bit in the way here.

> In general, iteration protocol is still the foundation for Future-like objects

That's not really reflected in the ABCs, is it?
History
Date User Action Args
2015-05-28 04:18:31scodersetrecipients: + scoder, gvanrossum, ncoghlan, vstinner, asvetlov, python-dev, yselivanov
2015-05-28 04:18:30scoderlinkissue24017 messages
2015-05-28 04:18:30scodercreate