@asyncio.coroutine vs async def

前端 未结 3 1173
傲寒
傲寒 2020-12-04 17:33

With the asyncio library I\'ve seen,

@asyncio.coroutine
def function():
    ...

and

async def function():
             


        
3条回答
  •  生来不讨喜
    2020-12-04 18:19

    From Python 3.5 coroutines formally became a distinct type and thus the async def syntax, along with await statements.

    Prior to that, Python 3.4 created coroutines by wrapping regular functions into generators, hence the decorator syntax, and the more generator-like yield from.

提交回复
热议问题