On 2015-04-28 11:59 PM, Greg wrote:
On 29/04/2015 9:49 a.m., Guido van Rossum wrote:
c) 'yield from' only accept coroutine objects from
generators decorated with 'types.coroutine'. That means
that existing asyncio generator-based coroutines will
happily yield from both coroutines and generators.
*But* every generator-based coroutine *must* be
decorated with `asyncio.coroutine()`. This is
potentially a backwards incompatible change.
See below. I worry about backward compatibility. A lot. Are you saying
that asycio-based code that doesn't use @coroutine will break in 3.5?
That seems unavoidable if the goal is for 'await' to only
work on generators that are intended to implement coroutines,
and not on generators that are intended to implement
iterators. Because there's no way to tell them apart
without marking them in some way.
Not sure what you mean by "unavoidable".
Before the last revision of the PEP it was perfectly fine
to use generators in 'yield from' in generator-based coroutines:
@asyncio.coroutine
def foo():
yield from gen()
and yet you couldn't do the same with 'await' (as it has
a special opcode instead of GET_ITER that can validate
what you're awaiting).
With the new version of the PEP - 'yield from' in foo()
would raise a TypeError. If we change it to a RuntimeWarning
then we're safe in terms of backwards compatibility. I just
want to see how exactly warnings will work (i.e. will they
occur multiple times at the same 'yield from' expression, etc)
Yury
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com