Skip to content

remove Irrational from hash(::Real) fallback #58375

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

adienes
Copy link
Member

@adienes adienes commented May 10, 2025

technically, this will (marginally) improve the mixing / randomness of hash(::Irrational) at the (marginal) cost of performance, since instead of 3*objectid(x) -h it becomes the standard hash(x::Any) = hash_finalizer(3h - objectid(x)), but I think in practice this is more or less NFC.

it just fixes the fact that hash(::Real) was not in fact generic over all <:Real inputs as evidenced by the fact that hash(::Irrational) was manually skipping that dispatch and re-implementing the fallback since Base.decompose has no Irrational method. this PR would tighten the signature and let hash(::Irrational) hit the real fallback.

@adienes adienes added design Design of APIs or of the language itself hashing labels May 10, 2025
@adienes adienes marked this pull request as draft May 10, 2025 19:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
design Design of APIs or of the language itself hashing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant