Write async code that never stops the event loop
Writing async does not help if there is no await to yield at. You watch a heartbeat skip, then fix the difference between gather and TaskGroup and the way cancellation is handled.
Projects / Programming languages / Advanced
What you end up with
A split_at_mut whose unsafe fits in six lines, a SAFETY: comment listing what has to hold, and five tests that pin down the edges.
Sign up for a free membership to read every free project. Already have an account? Please sign in.
Log in to send a report.
Writing async does not help if there is no await to yield at. You watch a heartbeat skip, then fix the difference between gather and TaskGroup and the way cancellation is handled.
You print the peak with tracemalloc and cut it in two directions: making one item smaller (__slots__) and holding fewer at once (generators). The second one is what pays.
Are your rules only enforced inside __init__? Then nothing stops anyone afterward. You check on every assignment with a descriptor, and work out derived values rather than holding them.