For Add, Mul and Term, once hash() is called, the field hash is filled and then it doesn't need to recompute the hash down to the subtree when hash() is called later.
But Sym, Pow and Div don't share this benefit.
It would be inefficient for, for example, the following expression.
https://github.com/JuliaSymbolics/SymbolicUtils.jl/blob/dcbe8613b1c6aa7572873b3308e0b1c50971296c/src/types.jl#L51-L61
https://github.com/JuliaSymbolics/SymbolicUtils.jl/blob/dcbe8613b1c6aa7572873b3308e0b1c50971296c/src/types.jl#L228-L256
For
Add
,Mul
andTerm
, oncehash()
is called, the fieldhash
is filled and then it doesn't need to recompute the hash down to the subtree whenhash()
is called later.But
Sym
,Pow
andDiv
don't share this benefit.It would be inefficient for, for example, the following expression.