Asynchronous processing is more efficient -- surely not?
Paul Moore
p.f.moore at gmail.com
Wed Apr 4 06:42:35 EDT 2018
On 4 April 2018 at 08:27, Steven D'Aprano
<steve+comp.lang.python at pearwood.info> wrote:
> "Asynchronous programming has been gaining a lot of traction in the past
> few years, and for good reason. Although it can be more difficult than
> the traditional linear style, it is also much more efficient."
>
> I can agree with the first part of the first sentence (gaining a lot of
> traction), and the first part of the second sentence (more difficult than
> the traditional style), but the second part? Asynchronous processing is
> *more efficient*?
I'd need to know what "efficient" meant. Obviously you're never going
to get more than 100% utilisation of a single core with async (because
of the GIL) but I can easily imagine async making more complete use of
that core by having less time spent waiting for I/O. Whether you
describe that as "more efficient" use of the CPU, or something else, I
don't know.
Honestly, that paragraph reads more like sales blurb than anything
else, so I'd be inclined to take it with a pinch of salt anyway. IMO,
async has proved useful for handling certain types of IO bound
workloads with lower overheads[1] than traditional multi-threaded or
multi-process designs. Whether it's a good fit for any particular
application is something you'd have to test, as with anything else.
Paul
[1] I found it really hard to avoid saying "more efficiently" there.
Not sure what that implies other than that the phrase means whatever
you want it to mean!!!
More information about the Python-list
mailing list