[Python-ideas] gevent-like Coroutines in Python

Chris Angelico rosuav at gmail.com
Tue Oct 30 08:41:04 EDT 2018

On Tue, Oct 30, 2018 at 11:36 PM Ron Reiter <ron.reiter at gmail.com> wrote:
> You are right that they are different, I was actually assuming that developers by default don't try to parallelize and would rather go ahead and write code to yield one function at a time, which is fine. The need to separate "await" from the invocation is something which is rarely used. Not sure what you mean about "threading" as it is still more efficient and lightweight to parallelize workers on an event loop rather than using blocking threads.

Okay, so it's actually nothing to do with asyncio.gather(). Sure.

So what you're looking for is JUST the removal of the "await"
keywords. As Greg already said, Guido considers the explicit await
markers as a feature, not a bug; these are the exact points where an
intrathread context switch can occur.

As to the efficiency of parallelizing on an event loop rather than
using threads, that's a tradeoff; threads aren't going anywhere just
because asyncio is here. When you want the extreme simplicity of "just
do this stuff, okay?", the easiest way to get it is to just use
threads, and pay a bit of overhead. You'll often find that the
overhead isn't actually all that significant until you get to extremes
of throughput - most Python apps are not trying to run tens of
thousands of concurrent TCP sockets, for instance.


More information about the Python-ideas mailing list