http://qs321.pair.com?node_id=11128354


in reply to do separate hashes share common keys?

In terms of documentation, the perldelta for 5.20.0 notes that "for example hash keys were already copy-on-write" when it describes the COW implementation.

https://metacpan.org/pod/distribution/perl/pod/perl5200delta.pod#Internal-Changes

I'm not sure when it was introduced, but jcb's estimate in 11128352 looks reasonable to me.

(Edit: look for the ninth bullet point under the link to find the quoted text).

  • Comment on Re: do separate hashes share common keys?

Replies are listed 'Best First'.
Re^2: do separate hashes share common keys?
by LanX (Saint) on Feb 14, 2021 at 13:05 UTC
    thanks, but I'm confused about the "for example hash keys were already copy-on-write" comment.

    By principle hash-keys are (and must be) immutable.

    Immutable data can be shared w/o allocating new memory, while mutable objects need to be copied to separate space.

    COW is a performance trick to "lazily" delay that copy to the time when the mutation (the write) happens.

    So there must be a misunderstanding, since hash-keys are always read-only, there is never a write.

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery