GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Align builtin iterator controls and callback lifetimes by youknowdot · Pull Request #9699 · RustPython/RustPython

Conversation

@youknowdot

@youknowdot youknowdot commented Nov 4, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

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.

  • Export reversed as its actual subclassable type, bind its constructor through shared argument metadata, and honor special-method None and sequence checks without binding getitem merely to check support.
  • Reconstruct reductions through the actual iterator type. Forward weakproxy reversal to the referent's ordinary method rather than the builtin fallback, preserving instance overrides and dead-referent errors.

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

  • PyType::call retains separate init_args for ordinary type calls. The new cleanup order governs constructor-owned references/direct constructor paths; it does not establish complete ordinary-call finalizer parity while inherited object.init/FuncArgs still own those values.
  • Generic iterator wrappers may already normalize user StopIteration subclasses before these consumers receive them. The patch preserves original native errors where they remain available.
  • Zip's existing result allocation lacks CPython's cached tuple, so result identity/refcounts and partial-result finalizer timing remain different.
  • Existing enumerate allocation-under-counter-lock behavior is unchanged. Reversed constructor raw argument ownership is retained through callbacks; inherited ordinary type-call init_args and shared binder teardown behavior remain outside this change.
  • Shared binder diagnostics and existing cross-thread scheduling/allocation timing remain outside scope. Old ownership/layout PRs may need textual reconciliation.

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@coderabbitai

coderabbitai Bot commented Nov 4, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Explain Change →

Caution

Review failed

The pull request is closed.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

  • X
  • Mastodon
  • Reddit
  • LinkedIn
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This was referenced Nov 4, 2026
Align native sequence iterator state and lifecycle #9701
Merged
Align weak-reference comparison and ownership controls #9710
Merged
Align builtin reduction callback controls #9718
Merged
Share builtin standard-stream callback controls #9720
Merged
@codspeed

codspeed Bot commented Nov 5, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 62 untouched benchmarks
⏩ 4 skipped benchmarks1


Comparing youknowdot:fix/builtin-iterator-controls-20261104 (46ff99a) with main (7e49b84)2

Open in CodSpeed

Footnotes

  1. 4 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

  2. No successful run was found on main (702ffe7) during the generation of this report, so 7e49b84 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

youknowone
youknowone approved these changes Nov 5, 2026
View reviewed changes
youknowdot added 6 commits November 6, 2026 13:12
@youknowdot @codex
Align builtin iterator controls and callback lifetimes
5d227f7
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
@youknowdot @codex
Share generic sequence iterator callback controls
2bdbe04
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
@youknowdot @codex
Share strict iterator ssize conversion
3ac5895
Assisted-by: OpenAI Codex:model version not exposed
@youknowdot @codex
Align reversed construction and proxy dispatch
163c697
Assisted-by: OpenAI Codex:model version not exposed
@youknowdot @codex
Return reversed reduction without redundant result wrapper
2673882
Assisted-by: OpenAI Codex:model version not exposed
@youknowdot @codex
Return integers from byte sequence item slots
46ff99a
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
@youknowdot
youknowdot force-pushed the fix/builtin-iterator-controls-20261104 branch from 0c0bf4c to 46ff99a Compare November 6, 2026 04:17
youknowone
youknowone approved these changes Nov 6, 2026
View reviewed changes
@youknowone
youknowone marked this pull request as ready for review November 6, 2026 11:23
@youknowone
youknowone merged commit 1f6c4dc into RustPython:main Nov 6, 2026
29 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 6, 2026

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-06T11:23:14.200237Z
We couldn’t complete this review. Comment @codex review to try again.
46ff99a Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 6, 2026

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@youknowone youknowone youknowone approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@youknowdot @youknowone
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.