AutoHashEquals.jl
AutoHashEquals.jl copied to clipboard
Permit `@auto_hash_equals cached=true` with mutable struct types.
Either
- Require that all declared fields are
const, or - Add
constto each declared field (with a warning?) if not already declared so.
The advantage of doing this is that we get both an efficient hash code and an efficient equality (because of the === shortcut)
const on a field is only available in Julia 1.8 and later.
(The disadvantage is that every field access has to go to the heap. With an immutable struct, fields can be pulled onto the stack or into registers, which can improve the performance of a function that spends a lot of time with those fields. If you're just hopping off to the next child in a tree or something, this probably matters less.)