Just another Perl shrine | |
PerlMonks |
Re: do separate hashes share common keys?by dave_the_m (Monsignor) |
on Feb 14, 2021 at 09:53 UTC ( [id://11128357]=note: print w/replies, xml ) | Need Help?? |
Yes, each interpreter has what's called the shared string table, which is a big hash which uses every key currently in use by most hashes, using a reference counting mechanism. So if you create 1000 objects with the same key "foobar", there will be a single 'HEK' entry in the shared table for the string "foobar", and all the individual hashes will have a pointer to it.
Note that it is (mostly) unrelated to the Copy-on-Write mechanism. Dave.
In Section
Seekers of Perl Wisdom
|
|