For this you have to create the image of the merged hash in memory. If you have incredibly large data structures ( as I do ) this may be a wasting of resources ( in the extreme case this can cause the program to run out of memory ). In may solution it is enough to query the keys of both hashes without ever creating the merged hash itself.