Skip to content
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

add 2-arg hash function #1054

Merged
merged 4 commits into from Jan 8, 2024
Merged

add 2-arg hash function #1054

merged 4 commits into from Jan 8, 2024

Conversation

jverzani
Copy link
Contributor

On discourse (https://discourse.julialang.org/t/sympy-sym-s-as-keys-in-dicts/103995) the issue of using tuples of symbolic keys let to the realization that the 2 argument form of hash resolved to a different code path than the 1-argument form. This consolidates the two.

If this PR is reasonable, it might also make sense to remove the precompile statement for hashsalt and the hashsalt function.

The approach taken in PythonCall might provide an alternative. (Base.hash(x::Py, h::UInt) = reinterpret(UInt, Int(pyhash(x))) - 3h)

@codecov-commenter
Copy link

codecov-commenter commented Sep 18, 2023

Codecov Report

Attention: 2 lines in your changes are missing coverage. Please review.

Comparison is base (e54c4ee) 67.75% compared to head (3c7a753) 67.78%.

Files Patch % Lines
src/PyCall.jl 66.66% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1054      +/-   ##
==========================================
+ Coverage   67.75%   67.78%   +0.03%     
==========================================
  Files          20       20              
  Lines        2025     2024       -1     
==========================================
  Hits         1372     1372              
+ Misses        653      652       -1     
Flag Coverage Δ
unittests 67.78% <66.66%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

src/PyCall.jl Outdated
@@ -273,20 +273,20 @@ end
const pysalt = hash("PyCall.PyObject") # "salt" to mix in to PyObject hashes
hashsalt(x) = hash(x, pysalt)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably just delete this function (also from src/precompile.jl).

@stevengj
Copy link
Member

LGTM. I agree about removing hashsalt.

I can't remember why I did it this way — may be from quite an old Julia version.

src/PyCall.jl Outdated Show resolved Hide resolved
@jverzani
Copy link
Contributor Author

Thanks! Let me know if there is anything else to be done here.

@MilesCranmer
Copy link
Contributor

@stevengj would it be possible to merge this? Thanks! - Miles

src/PyCall.jl Outdated Show resolved Hide resolved
@stevengj stevengj merged commit 1c074e2 into JuliaPy:master Jan 8, 2024
14 of 18 checks passed
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.

None yet

4 participants