cpython/Doc/c-api
Yury Selivanov 5376ba9630 Issue #24400: Introduce a distinct type for 'async def' coroutines.
Summary of changes:

1. Coroutines now have a distinct, separate from generators
   type at the C level: PyGen_Type, and a new typedef PyCoroObject.
   PyCoroObject shares the initial segment of struct layout with
   PyGenObject, making it possible to reuse existing generators
   machinery.  The new type is exposed as 'types.CoroutineType'.

   As a consequence of having a new type, CO_GENERATOR flag is
   no longer applied to coroutines.

2. Having a separate type for coroutines made it possible to add
   an __await__ method to the type.  Although it is not used by the
   interpreter (see details on that below), it makes coroutines
   naturally (without using __instancecheck__) conform to
   collections.abc.Coroutine and collections.abc.Awaitable ABCs.

   [The __instancecheck__ is still used for generator-based
   coroutines, as we don't want to add __await__ for generators.]

3. Add new opcode: GET_YIELD_FROM_ITER.  The opcode is needed to
   allow passing native coroutines to the YIELD_FROM opcode.

   Before this change, 'yield from o' expression was compiled to:

      (o)
      GET_ITER
      LOAD_CONST
      YIELD_FROM

   Now, we use GET_YIELD_FROM_ITER instead of GET_ITER.

   The reason for adding a new opcode is that GET_ITER is used
   in some contexts (such as 'for .. in' loops) where passing
   a coroutine object is invalid.

4. Add two new introspection functions to the inspec module:
   getcoroutinestate(c) and getcoroutinelocals(c).

5. inspect.iscoroutine(o) is updated to test if 'o' is a native
   coroutine object.  Before this commit it used abc.Coroutine,
   and it was requested to update inspect.isgenerator(o) to use
   abc.Generator; it was decided, however, that inspect functions
   should really be tailored for checking for native types.

6. sys.set_coroutine_wrapper(w) API is updated to work with only
   native coroutines.  Since types.coroutine decorator supports
   any type of callables now, it would be confusing that it does
   not work for all types of coroutines.

7. Exceptions logic in generators C implementation was updated
   to raise clearer messages for coroutines:

   Before: TypeError("generator raised StopIteration")
   After: TypeError("coroutine raised StopIteration")
2015-06-22 12:19:30 -04:00
..
abstract.rst
allocation.rst
apiabiversion.rst
arg.rst Doc clarification / edification on the semantics of the 'w*' format unit. 2015-04-13 11:30:56 -04:00
bool.rst
buffer.rst Whitespace. 2015-02-01 19:46:31 +01:00
bytearray.rst #23088: Clarify null termination of bytes and strings in C API. 2015-05-13 20:31:53 -04:00
bytes.rst #23088: Clarify null termination of bytes and strings in C API. 2015-05-13 20:31:53 -04:00
capsule.rst
cell.rst
code.rst
codec.rst Issue #19676: Tweak documentation a bit. 2014-11-25 18:59:20 +02:00
complex.rst
concrete.rst Issue #24400: Introduce a distinct type for 'async def' coroutines. 2015-06-22 12:19:30 -04:00
conversion.rst Fixed documentation of functions with const char* arguments. 2015-06-21 17:11:21 +03:00
coro.rst Issue #24400: Introduce a distinct type for 'async def' coroutines. 2015-06-22 12:19:30 -04:00
datetime.rst
descriptor.rst
dict.rst
exceptions.rst Fixed documentation of functions with const char* arguments. 2015-06-21 17:12:16 +03:00
file.rst
float.rst
function.rst
gcsupport.rst
gen.rst Issue #24400: Introduce a distinct type for 'async def' coroutines. 2015-06-22 12:19:30 -04:00
import.rst Fixed documentation of functions with const char* arguments. 2015-06-21 17:12:16 +03:00
index.rst
init.rst Fixed documentation of functions with const char* arguments. 2015-06-21 17:12:16 +03:00
intro.rst
iter.rst
iterator.rst
list.rst
long.rst
mapping.rst Fixed documentation of functions with const char* arguments. 2015-06-21 17:11:21 +03:00
marshal.rst Fixed documentation of functions with const char* arguments. 2015-06-21 17:11:21 +03:00
memory.rst Merge: #23957: fix typo. 2015-04-14 16:42:49 -04:00
memoryview.rst
method.rst
module.rst PEP 489: Multi-phase extension module initialization 2015-05-23 22:24:10 +10:00
none.rst
number.rst
objbuffer.rst
object.rst Fixed a typo. 2015-05-02 19:24:41 +03:00
objimpl.rst
refcounting.rst
reflection.rst
sequence.rst Issue #23081: Document that PySequence_List also accepts iterables. 2015-03-13 02:55:45 +02:00
set.rst
slice.rst
stable.rst
structures.rst Regenerated pydoc-topics and fixed bad/suspicious doc markup for Python 3.5.0a4. 2015-04-19 13:50:12 -07:00
sys.rst Fixed documentation of functions with const char* arguments. 2015-06-21 17:12:16 +03:00
tuple.rst
type.rst Clean up the docs of PyObject_IsSubclass and PyObject_IsInstance, and mention that they call the PEP 3119 methods. 2014-10-06 14:38:53 +02:00
typeobj.rst Issue 24017: Drop getawaitablefunc and friends in favor of unaryfunc. 2015-05-28 11:21:31 -04:00
unicode.rst Fixed documentation of functions with const char* arguments. 2015-06-21 17:12:16 +03:00
utilities.rst
veryhigh.rst
weakref.rst