Skip to content

Fix math reduction conversion and numeric protocol handling - #9666

Merged
youknowone merged 1 commit into
RustPython:mainfrom
youknowdot:fix/math-reductions-20261103
Nov 5, 2026
Merged

youknowone merged 1 commit into
RustPython:mainfrom
youknowdot:fix/math-reductions-20261103

Conversation

@youknowdot

Copy link
Copy Markdown
Contributor

Summary

Align math reduction protocol handling with CPython 3.15:

  • Materialize both dist points and check dimensions before converting coordinates; convert matching coordinates in p/q order and read tuple subclasses directly.
  • Restrict prod fast paths to exact builtin types, preserving float subclass multiplication and empty-product results. Simplify the staged accumulator and enable its integer path for explicit integer starts.
  • Preserve sumprod iterator construction and exception order, including errors paired with exhaustion. Include bool weights in compensated float accumulation.

Uses existing typed argument binding, sequence conversion, arithmetic, and pymath norm/compensation machinery. No tests, Python files, or workflows changed.

Source comparison

Compared against CPython revision d220409a13b77de7a6c30abe16ea90db01528edc:

Validation

  • Passed rustfmt and git diff --check.
  • Passed 12 bounded CPython 3.15.0 reference probes covering dist conversion and dimension-check order, tuple subclasses, prod subclass dispatch and empty results, sumprod iterator errors/construction order, and compensated cancellation with bool weights in both orientations.
  • Passed cargo check and strict Clippy (-D warnings) for rustpython-vm, rustpython-host_env, and rustpython-stdlib with rustpython-stdlib/threading, locked/offline and one build job, against base 0b081b0.
  • Workspace/C-API tests and RustPython test_math execution were not run. Reference probes establish expected CPython behavior, not RustPython runtime correctness. Native RustPython execution is held pending the required safety guard.

This does not claim full math parity. In particular, sumprod retains its existing O(n) buffered float-pair storage rather than implementing CPython’s streaming accumulator.

AI-assisted implementation and source comparison using OpenAI Codex (model version not exposed), directed by the maintainer.

Preserve dist materialization and coordinate conversion order, exact-type prod fast paths, and sumprod iterator errors and boolean compensation.

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

coderabbitai Bot commented Nov 3, 2026 •

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

@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/math-reductions-20261103 (12c721a) with main (0b081b0)

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. ↩

@youknowone
youknowone marked this pull request as ready for review November 5, 2026 02:08
@youknowone
youknowone merged commit 14a28e9 into RustPython:main Nov 5, 2026
21 checks passed
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-11-05T02:08:38.260298Z
We couldn’t complete this review. Comment @codex review to try again.
12c721a 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.

@chatgpt-codex-connector

Copy link
Copy Markdown

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

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.

2 participants