Skip to content

Migrate in-tree Hashable implementations to fixed __hash__ slots - #10211

Draft
youknowone wants to merge 5 commits into
RustPython:mainfrom
youknowone:direct-hash-slots-dec06
Draft

youknowone wants to merge 5 commits into
RustPython:mainfrom
youknowone:direct-hash-slots-dec06

Conversation

@youknowone

@youknowone youknowone commented Dec 6, 2026 •

Copy link
Copy Markdown
Member

Convert the in-tree Hashable implementations to fixed-signature native #[pymethod] __hash__ slots. Keep the legacy Rust trait as deprecated migration guidance. Preserve cached hashes, existing typed frozenset and timedelta calls, and unhashable weak proxies. This branch incorporates merged #10212 without changing its repr formatting or registered signatures.

The existing vm_special_method.py snippet covers direct descriptors, inherited/dynamic overrides, cached containers, and exception propagation. Hooks passed. The full candidate passed strict Linux Clippy before integration with merged #10212; CPython 3.15.2 and the earlier Rust control passed the snippet and 59 canonical hash/range tests. Exact integrated-head validation is delegated to CI; no performance claim.

Assisted by ChatGPT.

Register the exact native HashFunc directly with the Python name. Keep the Hashable trait implementations for Rust callers and share their calculation with the native slot.

Assisted-by: ChatGPT:version-not-exposed
@coderabbitai

coderabbitai Bot commented Dec 6, 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

Keep each hash calculation in the fixed-signature __hash__ method. Use the same direct repr adapters as the companion Representable migration in these two payloads.

Assisted-by: ChatGPT:version-not-exposed
Keep the native slot signature and move range formatting directly into the registered slot.

Assisted-by: ChatGPT:version-not-exposed
Integrate the merged direct __repr__ implementation without changing formatting. Keep the legacy Hashable trait deprecated for downstream migration, and do not make weak proxies hashable.

Assisted-by: ChatGPT:version-not-exposed
@youknowone youknowone changed the title Register bytes and range __hash__ slots with #[pymethod] Migrate in-tree Hashable implementations to fixed __hash__ slots Dec 6, 2026
Keep the direct hash migration unchanged while rolling in the macOS and browser WASM fixes from RustPython#10213 and current compiler main.

Assisted-by: ChatGPT: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