3 ms·
> It's a big neon sign that says "hey, this function call is expensive". IMO the more important part is that it can yield control. Half the advantage of cooper
by mananaysiempre 2y ago
> It's a big neon sign that says "hey, this function call is expensive".
IMO the more important part is that it can yield control. Half the advantage of cooperative multithreading is knowing where you may yield control makes sharing memory more or less workable.
I also like Trio’s model: if it’s async, it will yield control, even if the result is already available so it doesn’t technically have to. Makes it more difficult to accidentally starve other tasks. (I suppose I also have to mention Curio’s model: if it’s async, it’s a scheduler upcall, whether yielding or not. But for all that Curio deserves credit for freeing Python from asyncio hell, I just don’t find myself caring about things being scheduler upcalls or not.)