|
|
|
|
|
by ketchupdebugger
1066 days ago
|
|
Looking at python's asyncio coroutine library, they are just mocking multithreading with asyncio.gather. Since coroutines can be executed in any order they are not really control-flow mechanisms. The selling point of coroutines over traditional threads is its lightweight but its moot since goroutines has similar memory cost to coroutines. The only real benefit is that coroutines are non blocking while goroutines may be blocked. There is no real benefit of having python's coroutine in go since goroutines does the same but better. |
|
But when you have a construct that has their own call stacks, it's a relatively small step to implement lightweight threads with it.
Since doing concurrency happens much more often than any other smart use of coroutines, many people conflate the two.
I sometimes see this confusion in discussions about Kotlin's coroutines. An example of using coroutines that is not about concurrency: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.sequence...