From: Martin Panter Date: Wed, 7 Oct 2015 10:01:04 +0000 (+0000) Subject: Issue #25286: Merge dictionary view glossary from 3.4 into 3.5 X-Git-Tag: v3.5.1rc1~201 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=446977c080bc82f37b13d89f1de82cb1670caccf;p=python Issue #25286: Merge dictionary view glossary from 3.4 into 3.5 --- 446977c080bc82f37b13d89f1de82cb1670caccf diff --cc Doc/library/collections.abc.rst index 563c1bc4c5,d73f05ae56..d9b93ad262 --- a/Doc/library/collections.abc.rst +++ b/Doc/library/collections.abc.rst @@@ -150,58 -122,8 +150,58 @@@ ABC Inherits fro KeysView ValuesView - ABCs for mapping, items, keys, and values :term:`views `. + ABCs for mapping, items, keys, and values :term:`views `. +.. class:: Awaitable + + ABC for :term:`awaitable` objects, which can be used in :keyword:`await` + expressions. Custom implementations must provide the :meth:`__await__` + method. + + :term:`Coroutine` objects and instances of the + :class:`~collections.abc.Coroutine` ABC are all instances of this ABC. + + .. note:: + In CPython, generator-based coroutines (generators decorated with + :func:`types.coroutine` or :func:`asyncio.coroutine`) are + *awaitables*, even though they do not have an :meth:`__await__` method. + Using ``isinstance(gencoro, Awaitable)`` for them will return ``False``. + Use :func:`inspect.isawaitable` to detect them. + + .. versionadded:: 3.5 + +.. class:: Coroutine + + ABC for coroutine compatible classes. These implement the + following methods, defined in :ref:`coroutine-objects`: + :meth:`~coroutine.send`, :meth:`~coroutine.throw`, and + :meth:`~coroutine.close`. Custom implementations must also implement + :meth:`__await__`. All :class:`Coroutine` instances are also instances of + :class:`Awaitable`. See also the definition of :term:`coroutine`. + + .. note:: + In CPython, generator-based coroutines (generators decorated with + :func:`types.coroutine` or :func:`asyncio.coroutine`) are + *awaitables*, even though they do not have an :meth:`__await__` method. + Using ``isinstance(gencoro, Coroutine)`` for them will return ``False``. + Use :func:`inspect.isawaitable` to detect them. + + .. versionadded:: 3.5 + +.. class:: AsyncIterable + + ABC for classes that provide ``__aiter__`` method. See also the + definition of :term:`asynchronous iterable`. + + .. versionadded:: 3.5 + +.. class:: AsyncIterator + + ABC for classes that provide ``__aiter__`` and ``__anext__`` + methods. See also the definition of :term:`asynchronous iterator`. + + .. versionadded:: 3.5 + These ABCs allow us to ask classes or instances if they provide particular functionality, for example::