I need to compare two arbitrary hashes as efficiently as possible. I don't need to know the differences between them, I just need to know if they are the same or not.
This is for the purpose of memoizing a constructor. I want new(%params1) and new(%params2) to return the same object iff %params1 = %params2 deeply. The Memoize module just joins the arguments with a string, it explicitly does not work with reference arguments.
Some options include
- Modules like Data::Compare and List::Compare, but these seem to be Perl-based
- Serializing with Storable and comparing the strings, but not sure if this is guaranteed to be canonical
Before trying to benchmark all of these for different parameter sets, I wanted to know if there was a standard (e.g. XS-based) solution.