Yury Selivanov <yseliva...@gmail.com> added the comment:

In general, implementing coroutines using 'yield' expressions (not 'yield 
from'!) is slower than async/await, because the former approach needs a 
trampoline to manage the stack, whereas CPython itself handles that for 'yield 
from' and 'await'.  I suspect that any difference in performance is not related 
to 'async/await' vs 'yield' performance.

The attached benchmarks compare two completely different frameworks: asyncio 
and asynq.  Both have different implementations of Task and Future and event 
loops primitives.  Perhaps both of them schedule IO events and callbacks 
differently as well.

asyncio could be slower because all tasks' callbacks must be scheduled through 
the event loop, whereas some frameworks like Twisted schedule them right away, 
which makes them faster in some specific micro-benchmarks.  Or there might be 
an issue with 'asyncio.gather()', which is stressed heavily in the attached 
benchmarks.

What I can say for sure, is that Python implementation of async/await has 
nothing to do with the results you observe.

I suggest to take a look at 'asyncio.gather', maybe we can make it faster.  
Please open a new issue if you find any ways to make it faster.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue32204>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to