diff options
author | Yury Selivanov <yselivanov@sprymix.com> | 2015-05-21 15:50:30 (GMT) |
---|---|---|
committer | Yury Selivanov <yselivanov@sprymix.com> | 2015-05-21 15:50:30 (GMT) |
commit | f3e40fac10fa240b98a709191c6648fdd585b55f (patch) | |
tree | e5f27a9f6b15c73d46e42dec738a2a8fb44f39d8 /Doc/c-api | |
parent | 548de2b210d60e4619c69269685ca66a59b29b6b (diff) | |
download | cpython-f3e40fac10fa240b98a709191c6648fdd585b55f.zip cpython-f3e40fac10fa240b98a709191c6648fdd585b55f.tar.gz cpython-f3e40fac10fa240b98a709191c6648fdd585b55f.tar.bz2 |
Issue 24180: Documentation for PEP 492 changes.
Diffstat (limited to 'Doc/c-api')
-rw-r--r-- | Doc/c-api/typeobj.rst | 65 |
1 files changed, 63 insertions, 2 deletions
diff --git a/Doc/c-api/typeobj.rst b/Doc/c-api/typeobj.rst index eb63705..ee33a67 100644 --- a/Doc/c-api/typeobj.rst +++ b/Doc/c-api/typeobj.rst @@ -220,9 +220,16 @@ type objects) *must* have the :attr:`ob_size` field. the subtype's :c:member:`~PyTypeObject.tp_setattr` and :c:member:`~PyTypeObject.tp_setattro` are both *NULL*. -.. c:member:: void* PyTypeObject.tp_reserved +.. c:member:: void* PyTypeObject.tp_as_async - Reserved slot, formerly known as tp_compare. + Pointer to an additional structure that contains fields relevant only to + objects which implement :term:`awaitable` and :term:`asynchronous iterator` + protocols at the C-level. See :ref:`async-structs` for details. + + .. versionadded:: 3.5 + + .. note:: + Formerly known as tp_compare and tp_reserved. .. c:member:: reprfunc PyTypeObject.tp_repr @@ -1332,3 +1339,57 @@ Buffer Object Structures :c:func:`PyBuffer_Release` is the interface for the consumer that wraps this function. + + +.. _async-structs: + + +Async Object Structures +======================= + +.. sectionauthor:: Yury Selivanov <yselivanov@sprymix.com> + + +.. c:type:: PyAsyncMethods + + This structure holds pointers to the functions required to implement + :term:`awaitable` and :term:`asynchronous iterator` objects. + + Here is the structure definition:: + + typedef struct { + getawaitablefunc am_await; + getaiterfunc am_aiter; + aiternextfunc am_anext; + } PyAsyncMethods; + +.. c:member:: getawaitablefunc PyAsyncMethods.am_await + + The signature of this function is:: + + PyObject *am_await(PyObject *self) + + The returned object must be an iterator, i.e. :c:func:`PyIter_Check` must + return ``1`` for it. + + This slot may be set to *NULL* if an object is not an :term:`awaitable`. + +.. c:member:: getaiterfunc PyAsyncMethods.am_aiter + + The signature of this function is:: + + PyObject *am_aiter(PyObject *self) + + Must return an :term:`awaitable` object. See :meth:`__anext__` for details. + + This slot may be set to *NULL* if an object does not implement + asynchronous iteration protocol. + +.. c:member:: aiternextfunc PyAsyncMethods.am_anext + + The signature of this function is:: + + PyObject *am_anext(PyObject *self) + + Must return an :term:`awaitable` object. See :meth:`__anext__` for details. + This slot may be set to *NULL*. |