⚡ Sangsakala Proxy 🏠 Home
Skip to content

Align set and dictionary view operation controls - #9693

Draft
youknowdot wants to merge 6 commits into
RustPython:mainfrom
youknowdot:set-controls-parity-20261104
Draft

youknowdot wants to merge 6 commits into
RustPython:mainfrom
youknowdot:set-controls-parity-20261104

Conversation

@youknowdot

@youknowdot youknowdot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Align native set operands, hashing, and related dictionary-view operations with CPython 3.15, using existing shared conversion and dictionary primitives.

  • Delay iterable conversion until each operation consumes an operand. Preserve self-operation behavior, cached native hashes, operation-specific dict/frozendict hashing, equality exceptions, and mutable-set fallback errors.
  • Match dictionary-view intersection dispatch and item-view symmetric difference using a private left copy, live right traversal, stored key hashes, and explicit cleanup order.
  • Reuse native set construction for reflected view operations without invoking subclass iterators or re-comparing clean copied keys. Select dense/sparse dictionary copies through the shared copy helper, and check live dict-merge mutation after each item, including skipped keys.
  • Keep temporary objects alive across callbacks, release them in the required order, and preserve safe deletion and length/hash snapshots. No per-function handwritten FuncArgs parsing.

The related dictionary-view work is folded into this PR rather than creating an overlapping change. Total: 788 changed lines in three production Rust files. No Python/Lib/test logic, markers, or workflows changed. Existing native test callers remain intact.

Validation

  • Independent exact-source and composition review against CPython 3.15.0 set operations and dictionary views/copy/merge.
  • Original set group: 116 implementation and 63 independent bounded CPython assertions. Dictionary-view group: 48 implementation and 42 independent assertions, including collisions, subclass overrides, live mutation, callback failures, and finalizer ordering. These are CPython/source checks, not RustPython execution.
  • Final focused host-env/VM/stdlib threading cargo check, normal all-targets Clippy, formatting, diff checks, and ordinary commit hooks passed. Four Clippy diagnostics exactly match unchanged main: one POSIX needless-collect and three ElementTree lints. Strict -D warnings remains blocked by that baseline; no suppression or unrelated baseline edits.
  • Native RustPython execution, full workspace/C-API runtime suites, and cross-platform tests were not run. Hosted CI is still required. Hash-table layout and same-size mutation traversal remain implementation-dependent; no identical-layout claim is made.

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

Shared type-name compatibility

The extracted dict/set hash-error helper uses the existing WTF-8 concatenation mechanism, preserving both type names and exception text when composed with #9700. Other set/dictionary-view behavior is byte-identical to the previously reviewed head. Independent in-memory composition review verified the exact previous head plus this narrow formatting change. Final focused host-env/VM/stdlib threading check, normal all-targets Clippy and ordinary hooks passed; the same four unchanged baseline diagnostics remain. No new runtime execution or test changes are claimed.

Intersection failure cleanup

The shared fallback now retains the current item through both membership testing and consuming set insertion. On failure it explicitly releases the iterator, partial result, and current item in that order. Accepted and rejected candidates are released before requesting the next item. Existing exact-set delegation, view-size swapping, and symmetric-difference paths are unchanged.

Independent frozen-source ownership review found no blocker. The additional pinned CPython reference checks passed 60 assertions across 16 groups plus 20 independent assertions, covering direct/reflected keys/items operations, membership and insertion failures, iterator failures, normal exhaustion, and candidate cleanup before the next request. These establish reference behavior and source review, not RustPython runtime execution. Cached item-tuple identity/reuse remains outside this change because it requires a separately reviewed tuple ownership/GC design.

Final threaded host-env/VM/stdlib check passed in 1m09s and all-targets Clippy in 2m24s, with exactly the same four baseline diagnostics (one POSIX and three ElementTree). Ordinary commit hooks passed. No native RustPython or full-suite execution is claimed.

Convert iterable operands when each operation reaches them, share precise
hash-error decoration, and preserve mutable-set keys for fallback lookup.
Reuse stored hashes according to each operation and align symmetric
difference comparison order while retaining reentrancy-safe table updates.

Assisted-by: OpenAI Codex:model version 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

Assisted-by: OpenAI Codex:model version not exposed
Assisted-by: OpenAI Codex:model version not exposed
@youknowdot youknowdot changed the title Align set operand and hashing controls with CPython Align set and dictionary view operation controls Nov 4, 2026
Preserve the extracted dict and set error helper while retaining qualified type names and exception messages through lossless concatenation.

Assisted-by: OpenAI Codex:model version not exposed
Retain the current dictionary-view item until its iterator and partial result have been released, including consuming set insertion failures.

Assisted-by: OpenAI Codex:model version not exposed
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