[HN Gopher] Tinyio: A tiny (~200 line) event loop for Python
___________________________________________________________________
Tinyio: A tiny (~200 line) event loop for Python
Author : tehnub
Score : 6 points
Date : 2025-07-22 22:02 UTC (4 days ago)
(HTM) web link (github.com)
(TXT) w3m dump (github.com)
| codethief wrote:
| > 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?
| dmerrick wrote:
| > 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.
___________________________________________________________________
(page generated 2025-07-26 23:00 UTC)