Skip to content

Commit

Permalink
add 2-arg hash function
Browse files Browse the repository at this point in the history
  • Loading branch information
jverzani committed Sep 18, 2023
1 parent 2a9f077 commit 3ffedc7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "PyCall"
uuid = "438e738f-606a-5dbb-bf0a-cddfbfd45ab0"
authors = ["Steven G. Johnson <[email protected]>", "Yichao Yu <[email protected]>", "Takafumi Arakaki <[email protected]>", "Simon Kornblith <[email protected]>", "Páll Haraldsson <[email protected]>", "Jon Malmaud <[email protected]>", "Jake Bolewski <[email protected]>", "Keno Fischer <[email protected]>", "Joel Mason <[email protected]>", "Jameson Nash <[email protected]>", "The JuliaPy development team"]
version = "1.96.1"
version = "1.96.2"

[deps]
Conda = "8f4d0f93-b110-5947-807f-2305c1781a2d"
Expand Down
10 changes: 5 additions & 5 deletions src/PyCall.jl
Original file line number Diff line number Diff line change
Expand Up @@ -273,20 +273,20 @@ end
const pysalt = hash("PyCall.PyObject") # "salt" to mix in to PyObject hashes
hashsalt(x) = hash(x, pysalt)

function hash(o::PyObject)
function hash(o::PyObject, salt::UInt64=pysalt)
if ispynull(o)
hashsalt(C_NULL)
hash(C_NULL, salt)
elseif is_pyjlwrap(o)
# call native Julia hash directly on wrapped Julia objects,
# since on 64-bit Windows the Python 2.x hash is only 32 bits
hashsalt(unsafe_pyjlwrap_to_objref(o))
hash(unsafe_pyjlwrap_to_objref(o), salt)
else
h = ccall((@pysym :PyObject_Hash), Py_hash_t, (PyPtr,), o)
if h == -1 # error
pyerr_clear()
return hashsalt(PyPtr(o))
return hash(PyPtr(o), salt)
end
hashsalt(h)
hash(h, salt)
end
end

Expand Down

0 comments on commit 3ffedc7

Please sign in to comment.