make iteration suspendable
Attempting to make it possible to suspend in the middle of a for loop, and experiments with making map and friends suspendable iterators too.
Summary by cubic
Makes iteration suspension-capable: for loops, comprehensions, and lazy map/filter advancement now pause at host calls and resume, instead of raising NotImplementedError when a user __next__ or callback suspends. map and filter are now lazy iterators (previously eager, returning a list), backed by a new MapFilter heap type that advances one item per suspension point, including unread files and user classes. A new continuation and compile_iteration_catcher frame handle suspended advancement while letting exceptions land in the outer try. Nested lazy advancement shares a bounded native dispatch stack, so deep callback chains raise RecursionError rather than overflowing the host stack.
Migration
- Dump format bumps to version 17; restored code no longer pins
map/filterto the old eager behavior, so previously compiled functions return lazy iterators after restore. - Synchronous consumers (
list(),sorted,itertoolsadaptors) still cannot suspend: they raise a catchableNotImplementedErrorinside the callback.