⚡ Sangsakala Proxy 🏠 Home
Skip to content

Fix math reduction conversion and numeric protocol handling - #9666

Draft
youknowdot wants to merge 1 commit into
RustPython:mainfrom
youknowdot:fix/math-reductions-20261103
Draft

youknowdot wants to merge 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

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