43 ms·
async is not comparable to threads: - async is concurrency - threads are parallelism They are not exclusives, the best approach is to be multi-threaded while e
by grodes 4y ago
async is not comparable to threads:
- async is concurrency
- threads are parallelism
They are not exclusives, the best approach is to be multi-threaded while each of the threads uses concurrency to prevent blocking the cpu.
- gpderetta 4y agoThreads are also for concurrency. In fact in python because of the GIL they are pretty much only for concurrency.
- ollien 4y ago> - async is concurrency - threads are parallelism Even this isn't necessarily true, especially given you can limit a process to a single core (or, if you use a single core system, lest we forget those exist!), or, in Python's case, the GIL! You can still have parallelism with asynchronous programming, it's just not necessarily guaranteed. IIRC tokio lets you spin up runtimes on different threads which (putting the above caveat) _can_ run in parallel.