-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Integer
can be hashed rapidly as well
#58440
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
base: master
Are you sure you want to change the base?
Conversation
@@ -209,7 +275,7 @@ end | |||
else | |||
pos = 1 | |||
i = buflen | |||
while i ≥ 48 | |||
if i > 48 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this was just an unrelated existing typo
@@ -182,7 +182,7 @@ isinteger(::AbstractIrrational) = false | |||
iszero(::AbstractIrrational) = false | |||
isone(::AbstractIrrational) = false | |||
|
|||
hash(x::Irrational, h::UInt) = 3*objectid(x) - h | |||
hash(x::Irrational, h::UInt) = 3h - objectid(x) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also unrelated to the meat of this PR, but makes hash(::Irrational)
more consistent with hash(::Any
@nanosoldier |
The package evaluation job you requested has completed - possible new issues were detected. Report summary❗ Packages that crashed1 packages crashed only on the current version.
5 packages crashed on the previous version too. ✖ Packages that failed24 packages failed only on the current version.
1444 packages failed on the previous version too. ✔ Packages that passed tests21 packages passed tests only on the current version.
5221 packages passed tests on the previous version too. ~ Packages that at least loaded4 packages successfully loaded only on the current version.
2925 packages successfully loaded on the previous version too. ➖ Packages that were skipped altogether921 packages were skipped on the previous version too. |
the |
as noted in #58388 (comment) , using
hash_bytes
forBigInt
limbs in isolation will break some hashing invariants. accordingly this PR updates also thehash_integer
fallback to use rapidhashsome surgery was needed to make
BigFloat
andRational
and such still match, but I think (hope?) I got it allbelow are some benchmarks. the
y
axis is nanoseconds and thex
axis is an input of size1234^x
, solength = 10
means inputhash(big(1234^10))
hashing
BigFloat
got a small bit slower, but this already allocates and already seems less common than hashingBigInt
(whose hashing remains non-allocating)