Show HN: Python micro event loop library (~250 LOC)
gist.github.com
gist.github.com
Last 2 lines, 735 and 736:
# Start the event loop with the main coroutine
event_loop(main())I then asked for Claude to write the docstrings and examples which increased by 500
What is the purpose of @dataclass on Task class?
No purpose. I think I added in the initial implementation and ended up not being required, but I forgot to remove
For the record, ~language~ additions i found interesting (excluding type-hints):
3.11:
(Base)ExceptionGroups ; (Base)Exception.add_note() + __notes__
modules: tomllib
3.10:
Parenthesized context managers
Structural Pattern Matching - match..:case..
builtins: aiter(), anext()
3.9:
dict | dict ; dict |= dict
for a in *x,*y: ... #no need of (*x,*y)
str.removeprefix , str.removesuffix
Any valid expression can now be used as a decorator
modules: zoneinfo , graphlib
3.8:
Assignment expressions
Positional-only parameters
f'{expr=}'
Dict comprehensions and literals compute First the key and Second value
3.7:
builtins: breakpoint()
__getattr__ and __dir__ of modules
modules: contextvars , dataclasses3.10 zip(strict=True) 3.11 asyncio.TaskGroup (structured concurrency) enabled by ExceptionGroup
3.12 itertools.batched(L, n) — it replaces zip([iter(L)]n)