Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> Somewhat unusually, our syntax uses yield rather than await, but the behaviour is the same. Await another coroutine with yield coro. Await on multiple with yield [coro1, coro2, ...] (a 'gather' in asyncio terminology; a 'nursery' in trio terminology).

Why, though?



> The reason is that await does not offer a suspension point to an event loop (it just calls `__await__` and maybe that offers a suspension point), so if we wanted to use that syntax then we'd need to replace `yield coro` with something like await `tinyio.Task(coro)`. The traditional syntax is not worth the extra class.


From the readme:

> ”Ever used asyncio and wished you hadn't?

Yes, that’s me. I always found the yield-based approach to coroutines much easier to reason about. It’s just a generator function.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: