[Python-ideas] Concurrency Modules

Nikolaus Rath Nikolaus at rath.org
Sun Jul 26 02:58:09 CEST 2015


On Jul 25 2015, "Sven R. Kunze" <srkunze-7y4VAllY4QU at public.gmane.org> wrote:
> startup impact | biggest                 | medium                     | smallest
> cpu impact     | biggest                 | medium                     | smallest
> memory impact  | biggest                 | medium                     | smallest
> purpose        | cpu-bound tasks         | i/o-bound tasks            | ???

I don't think any of these is correct. Unfortunately, I also don't think
there even is a correct version, the differences are simply not so
clear-cut.

On Unix, Process startup-cost can be high if you do fork() + exec(), but
if you just fork, it's as cheap as a thread. With asyncio, it's not
clear to me what exactly you'd define as the "startup impact" (the
creation of a future maybe? Or setting up the event loop?).

"CPU impact" as a category doesn't make any sense to me. If you execute
the same code it's going to take the same amount of (cumulative) CPU
time, no matter if this code runs in a separate thread, separate
process, or asynchronously.

"memory impact" is probably highest for separate processes, but I don't
see an obvious difference when using threads vs asyncio. Where did you
get this from?

As far as purpose is concerned, pretty much the only limitation is that
asyncio is not suitable for cpu-bound tasks. Any other combination is
possible and also most appropriate in specific circumstances.


Best,
-Nikolaus
-- 
GPG encrypted emails preferred. Key id: 0xD113FCAC3C4E599F
Fingerprint: ED31 791B 2C5C 1613 AF38 8B8A D113 FCAC 3C4E 599F

             »Time flies like an arrow, fruit flies like a Banana.«


More information about the Python-ideas mailing list