Cut memory, after measuring it
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.
Projects / Programming languages / Advanced
What you end up with
Async code rewritten so it never blocks the loop, a decision about where gather belongs and where TaskGroup does, and cancellation that reaches the end.
Sign up for a free membership to read every free project. Already have an account? Please sign in.
Log in to send a report.
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.
With Box<dyn Error> all you learn is that it failed. You write the possible failures out as an enum, so that adding one makes the compiler stop every caller. Up to where thiserror ends and anyhow begins.