Arc Riley schrieb am 25.06.2015 um 04:36:
A type slot for tp_as_async has already been added (which is good!) but we do not currently seem to have protocol functions for awaitable types.
I would expect to find an Awaitable Protocol listed under Abstract Objects Layer, with functions like PyAwait_Check, PyAwaitIter_Check, and PyAwaitIter_Next, etc.
Specifically its currently difficult to test whether an object is awaitable or an awaitable iterable, or use said objects from the c-api without relying on method testing/calling mechanisms.
FYI, Cython's latest master branch already implements PEP 492 (in Python 2.6+, using slots in Py3.2+). So you can just write "await x" and "async for ..." and get the expected slot calling code for it, or method calling fallback code in Python 2.x. That being said, I guess you're right that CPython would eventually want to extend the C-API here in order to cover the new protocols also for manually written C code. I'd wait with that a bit, though, until after Py3.5 is finally released and the actual needs for C code that want to use the new features become clearer. Stefan