⚡ Sangsakala Proxy 🏠 Home
Skip to content

Align native sequence iterator state and lifecycle - #9701

Draft
youknowdot wants to merge 1 commit into
RustPython:mainfrom
youknowdot:fix/native-sequence-iterator-controls-20261104
Draft

youknowdot wants to merge 1 commit into
RustPython:mainfrom
youknowdot:fix/native-sequence-iterator-controls-20261104

Conversation

@youknowdot

Copy link
Copy Markdown
Contributor

Summary

Align concrete sequence iterator state and lifecycle with CPython 3.15 in 437 changed production Rust lines across nine files.

  • Share signed cursor, owner retention, length hints, state validation and reduction snapshots through a native iterator helper. Concrete reads remain atomic without holding locks across Python allocation or owner release.
  • Preserve the distinct list, reverse-list, immutable sequence and bytearray negative-state rules, including reversible list states and irreversible bytearray exhaustion.
  • Validate strict integer state and native ssize overflow even after exhaustion. Share the borrowed conversion helper with the generic iterator companion in Align builtin iterator controls and callback lifetimes #9699, rather than duplicating conversion logic.
  • Correct empty reverse-list initialization, clamping and live length hints. Keep list/tuple fast paths and normal iteration on the same implementation.
  • Move bytes, bytearray and string result allocation outside iterator/storage locks, keep rejected string states from invalidating cached offsets, and register the retained owners for cyclic traversal.

The separate memoryview lifecycle changes extend #9692, which already owns memory iterator constructor validation. This PR does not duplicate that work. Existing generic sequence, dictionary/set, range and other PositionIterInternal consumers remain unchanged. No Python, Lib, tests, expected-failure markers or workflows changed.

Reference and validation

Source comparison uses CPython commit d220409a13b77de7a6c30abe16ea90db01528edc: list, tuple, string, bytes and bytearray.

Native RustPython execution was not performed. Full workspace/C-API suites and cross-platform runtime tests remain unrun. Hosted CI is required, and no runtime expected failure is claimed resolved. Existing cross-thread scheduling and allocation-timing differences outside these iterator controls remain outside scope.

AI-assisted implementation and independent review using OpenAI Codex; model version is not exposed.

Assisted-by: OpenAI Codex:model version not exposed
@coderabbitai

coderabbitai Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • 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

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant