[Python-Dev] async/await in Python; v2 (original) (raw)
Yury Selivanov yselivanov.ml at gmail.com
Wed Apr 22 21:24:41 CEST 2015
- Previous message (by thread): [Python-Dev] async/await in Python; v2
- Next message (by thread): [Python-Dev] async/await in Python; v2
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 2015-04-22 2:53 PM, Andrew Svetlov wrote:
On Wed, Apr 22, 2015 at 9:45 PM, Yury Selivanov <yselivanov.ml at gmail.com> wrote: [...]
If we forbid to call
async def
from regualr code how asyncio should work? I'd like to pushasync def
everywhere in asyncio API where asyncio.coroutine required. You'll have to use a wrapper that will do the following: async def foo(): return 'spam' @asyncio.coroutine def bar(): what = yield from foo.await(foo, *args, **kwargs) # OR: what = yield from awaitcall(foo, *args, **kwargs) If I cannot directly useyield from f()
withasync def f():
then almost everyyield from
inside asyncio library should be wrapped inawaitcall()
. Every third-party asyncio-based library should do the same. Also I expect a performance degradation onawaitcall()
calls.
I think there is another way... instead of pushing
GET_ITER ... YIELD_FROM
opcodes, we'll need to replace GET_ITER with another one:
GET_ITER_SPECIAL ... YIELD_FROM
Where "GET_ITER_SPECIAL (obj)" (just a working name) would check that if the current code object has CO_COROUTINE and the object that you will yield-from has it as well, it would push to the stack the result of (obj.await())
Yury
- Previous message (by thread): [Python-Dev] async/await in Python; v2
- Next message (by thread): [Python-Dev] async/await in Python; v2
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]