⚡ Sangsakala Proxy 🏠 Home
Skip to content

Align memoryview scalar, cast, and indexing controls - #9692

Draft
youknowdot wants to merge 4 commits into
RustPython:mainfrom
youknowdot:fix/memoryview-index-parity-20261104
Draft

youknowdot wants to merge 4 commits into
RustPython:mainfrom
youknowdot:fix/memoryview-index-parity-20261104

Conversation

@youknowdot

@youknowdot youknowdot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Align memoryview scalar formats, casts, indexing, and assignment with CPython 3.15.

  • Separate native memoryview scalar conversions from the general struct grammar. Exporter formats that scalar access cannot decode still support raw-byte operations and casts; equality uses struct-compatible parsing separately.
  • Match native integer range and release-check ordering, float32 overflow behavior, pointer int conversion, complex conversion errors, and normalized format diagnostics using existing conversion and unpack helpers.
  • Use derived raw argument binding and existing string/shape converters for cast validation. Encode the entire format as strict ASCII before first-NUL normalization, preserve release/contiguity/shape precedence, and validate signed shape bounds through existing integer helpers.
  • Validate shape/release/format at the appropriate indexing and iteration stage. Preserve tuple arity and per-dimension conversion/bounds ordering.
  • Handle overlapping slice assignments correctly, retain the RHS export through callbacks/copy, and preserve assignment error precedence and compatible optional @ formats.

The related scalar work is composed into this PR to avoid a second overlapping memoryview change. Total: 630 changed lines across six production Rust files. No Python/Lib/test logic, marker, or workflow changes.

Validation

  • Independent source review of the exact composition against CPython 3.15 memoryview.
  • Original indexing work passed 36 implementation and 108 independent CPython reference assertions. The scalar group passed 485 implementation and 150 independent bounded CPython assertions covering native widths/ranges, float/complex/pointer values, callbacks releasing or mutating the view, unsupported exporter formats, comparison, and overlap. The cast extension passed 2,980 implementation and 26,899 independent bounded CPython assertions covering format errors, NUL suffixes, surrogates, shape checks, subclass hooks, ownership and offset/storage preservation. These are CPython/source checks, not RustPython runtime validation.
  • Focused host-env/VM/stdlib threading cargo check, normal all-targets Clippy, formatting, diff checks, and normal commit hooks passed. Four Clippy diagnostics match unchanged main exactly: one POSIX needless-collect and three ElementTree lints. Strict -D warnings remains blocked by that unchanged baseline; no lint suppression or unrelated edits.
  • Native RustPython execution, full workspace and C-API runtime suites, and cross-platform tests were not run. Hosted CI remains required.

The shared binder retains some malformed-call diagnostic wording differences from Clinic; no per-function parser was added. Restricted-view cast ordering was source-reviewed rather than exercised with an artificial exporter. Inherited half-precision signaling-NaN payload behavior and general comparison parser corners remain outside this change. No claim of complete diagnostic or NaN payload parity is made.

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

Copy overlapping self assignments, acquire source buffers before slice
callbacks, and convert tuple indices one dimension at a time through the
shared descriptor bounds logic. Reuse sequence index conversion for size
errors and preserve CPython release/error precedence.

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

Assisted-by: OpenAI Codex:model version not exposed
@youknowdot youknowdot changed the title Align memoryview indexing and slice assignment Align memoryview scalar and indexing controls Nov 4, 2026
Assisted-by: OpenAI Codex:model version not exposed
@youknowdot youknowdot changed the title Align memoryview scalar and indexing controls Align memoryview scalar, cast, and indexing controls Nov 4, 2026
Assisted-by: OpenAI Codex:model version not exposed
@codspeed

codspeed Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 62 untouched benchmarks
⏩ 4 skipped benchmarks1


Comparing youknowdot:fix/memoryview-index-parity-20261104 (28382c7) with main (484cb61)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 (81e3634) during the generation of this report, so 484cb61 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

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