← Winnitude! Search  ·  Reader Mode (1496 ms)
Links: Stay in Reader Retro Site Converter Retro Mode: OFF Original Page ↗
GITHUB · 39 LINKS

Migrate in-tree Hashable implementations to fixed __hash__ slots by youknowone · Pull Request #10211 · RustPython/RustPython

Repository navigation

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


Draft
youknowone wants to merge 6 commits into RustPython:main from youknowone:direct-hash-slots-dec06
Draft

Migrate in-tree Hashable implementations to fixed __hash__ slots #10211 youknowone wants to merge 6 commits into RustPython:main from youknowone:direct-hash-slots-dec06

Conversation

youknowone commented Dec 6, 2026 · edited Loading



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 bytes and range hash slots with #[pymethod] 9e8cf7f
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
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

youknowone added 3 commits December 6, 2026 15:08 Remove legacy special-method trait implementations for bytes and range 05d2085
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
Fix lint in the direct bytes and range repr adapters 260f158
Keep the native slot signature and move range formatting directly into the registered slot.

Assisted-by: ChatGPT:version-not-exposed
Migrate all in-tree Hashable implementations to fixed __hash__ slots fd51764
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 changed the title Register bytes and range __hash__ slots with #[pymethod] Migrate in-tree Hashable implementations to fixed __hash__ slots Dec 6, 2026 youknowone added 2 commits December 6, 2026 19:59 Merge main to pick up platform repr fixes a2a2bd1
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
Simplify native hash and repr signatures c08efdc
Use imported names in handwritten special-method signatures. Remove the redundant unhashable marker from slice and frozenset and cover native hash inheritance and disabling in the existing snippet.

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

1 participant