Repository navigation
Align builtin iterator controls and callback lifetimes - #9699
youknowone merged 6 commits into
Conversation
|
Caution Review failedThe pull request is closed.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
Merging this PR will not alter performance
Comparing Footnotes
|
Share map and zip argument and strict controls, preserve filter subclasses, and release callable iterator state around reentrant callbacks. Assisted-by: OpenAI Codex:model version not exposed
Keep sequence callbacks outside state locks and match forward/reverse state, exhaustion and signed-wrap behavior without changing native container iterators. Assisted-by: OpenAI Codex:model version not exposed
Assisted-by: OpenAI Codex:model version not exposed
Assisted-by: OpenAI Codex:model version not exposed
Assisted-by: OpenAI Codex:model version not exposed
Generic reversed iteration uses the sequence item slot. Match byte indexing and CPython by returning integer values for bytes and bytearray rather than single-byte bytes objects. Assisted-by: OpenAI Codex:model version not exposed
0c0bf4c to
46ff99a
Compare
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Summary
Group builtin iterator controls and callback lifetimes in 817 changed production lines (+588/-229):
Reuse typed argument binders and share map/zip strict conversion, iterator acquisition and mismatch handling. Convert strict before acquiring iterators, propagate setstate conversion errors and preserve nonstrict native exceptions.
Retain constructor-owned raw inputs across conversion callbacks and share their cleanup instead of per-function parsing.
Preserve filter subclasses in reduction and align filter result cleanup.
Compare callable-iterator sentinels in CPython's order, latch callable StopIteration, and release exhausted callable/sentinel owners outside locks.
Snapshot callable reduction state before tuple allocation. Release the temporary sentinel comparison owner before truth conversion, preserving reentrant finalizer behavior.
Share generic sequence/reverse iterator state without holding locks across sequence callbacks, allocation or owner release. Match empty/reverse exhaustion, strict signed state conversion, exception clearing and reentrant live-versus-captured indices.
Preserve the pinned CPython signed-wrap behavior and negative-index normalization when callbacks change the live forward index to the native maximum.
Nine production Rust files. No Python, Lib, tests, expected-failure markers or workflows changed. Shared list/tuple/range/itertools implementations are untouched.
The strict signed-size conversion now uses the same borrowed helper as #9701, avoiding duplicate conversion logic while preserving the original state argument through mutation. This companion has no dependency on the native iterator engine.
Reference and validation
Compared with CPython commit d220409a13b77de7a6c30abe16ea90db01528edc: builtin iterator controls and callable iterators.
9,416 bounded CPython/source-model assertions passed, with additional independent lifecycle/error oracles. Coverage includes strict conversion and mismatch precedence, repeated calls, native StopIteration subclass data, state reentry, subclass reduction, callable equality/truth callbacks, resource release and resurrection. These are reference/model checks, not execution of the Rust implementation.
Independent exact-source review passed after correcting two findings: tuple allocation while a callable state read guard was held, and sentinel ownership extending across a reentrant truth callback. Focused host-env/VM/stdlib threading cargo check, normal all-targets Clippy and ordinary commit hooks passed. Clippy emitted exactly four unchanged main-baseline diagnostics: one POSIX needless-collect and three ElementTree lints. Strict -D warnings remains blocked by that baseline; no warnings were suppressed.
Native RustPython execution was not performed. Full workspace/C-API suites and cross-platform runtime tests remain unrun. Hosted CI is required; no runtime expected failure is claimed resolved.
The generic sequence/reverse companion passed 16,003 further bounded CPython/source-model assertions and independent callback/finalizer probes. Independent review caught and corrected reentrant MAX wrapping and verified the final composition preserves the original map/zip/filter/callable code byte-for-byte. Reference: sequence iterators and reversed.
Remaining limits
The reversed constructor/proxy companion passed 86 bounded pinned-CPython assertions and independent source/lifecycle/metadata review. All generic iterator state mechanics remain unchanged by this companion.
AI-assisted contribution by OpenAI Codex, disclosed in the commit trailer.