File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed
Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -332,6 +332,18 @@ function Base.hash(s::BasicSymbolic, salt::UInt)::UInt
332332 end
333333end
334334
335+ """
336+ $(TYPEDSIGNATURES)
337+
338+ Calculates a hash value for a `BasicSymbolic` object, incorporating both its metadata and
339+ symtype.
340+
341+ This function provides an alternative hashing strategy to `Base.hash` for `BasicSymbolic`
342+ objects. Unlike `Base.hash`, which only considers the expression structure, `hash2` also
343+ includes the metadata and symtype in the hash calculation. This can be beneficial for hash
344+ consing, allowing for more effective deduplication of symbolically equivalent expressions
345+ with different metadata or symtypes.
346+ """
335347hash2 (s:: BasicSymbolic ) = hash2 (s, zero (UInt))
336348function hash2 (s:: BasicSymbolic{T} , salt:: UInt ):: UInt where {T}
337349 hash (metadata (s), hash (T, hash (s, salt)))
You can’t perform that action at this time.
0 commit comments