Stefan Behnel added the comment: > 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? ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue24017> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com