On 13/06/20 3:02 pm, Steven D'Aprano wrote:
Coroutines are lighter weight than threads because they don't need all the machinary to pre-emptively run threads in parallel; threads are lighter weight than processes because they don't need to be in separate memory spaces enforced by the OS.
Well, sort of. Threading mechanisms provided by typical desktop OSes tend to come with a lot of baggage that isn't strictly necessary for the concept of preemptive scheduling. A real time OS designed for embedded devices, for instance, likely provides preemptive threads with far less overhead.