Re: [Python-Dev] async/await in Python; v2

2015年4月22日 16:11:22 -0700

Hello,
On 2015年4月22日 13:31:18 -0700
Guido van Rossum <[email protected]> wrote:
> On Wed, Apr 22, 2015 at 1:10 PM, Andrew Svetlov
> <[email protected]> wrote:
> 
> > On Wed, Apr 22, 2015 at 10:44 PM, PJ Eby <[email protected]>
> > wrote:
> > > On Tue, Apr 21, 2015 at 1:26 PM, Yury Selivanov
> > > <[email protected]>
> > wrote:
> > >> It is an error to pass a regular context manager without
> > >> ``__aenter__`` and ``__aexit__`` methods to ``async with``. It
> > >> is a ``SyntaxError`` to use ``async with`` outside of a
> > >> coroutine.
> > >
> > > I find this a little weird. Why not just have `with` and `for`
> > > inside a coroutine dynamically check the iterator or context
> > > manager, and either behave sync or async accordingly? Why must
> > > there be a *syntactic* difference?
> >
> > IIRC Guido always like to have different syntax for calling regular
> > functions and coroutines.
> > That's why we need explicit syntax for asynchronous context managers
> > and iterators.
> >
> 
> To clarify: the philosophy behind asyncio coroutines is that you
> should be able to tell statically where a task may be suspended
> simply by looking for `yield from`. This means that *no* implicit
> suspend points may exist, and it rules out gevent, stackless and
> similar microthreading frameworks.
I always wanted to ask - does that mean that Python could have
symmetric coroutines (in a sense that it would be Pythonic feature), as
long as the call syntax is different from a function call?
E.g.:
sym def coro1(val):
 while True:
 val = coro2.corocall(val)
sym def coro2(val):
 while True:
 val = coro1.corocall(val)
coro1.call(1)
-- 
Best regards,
 Paul mailto:[email protected]
_______________________________________________
Python-Dev mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to