Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: do separate hashes share common keys?

by swl (Priest)
on Feb 14, 2021 at 06:44 UTC ( #11128354=note: print w/replies, xml ) Need Help??


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 (Cardinal) 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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://11128354]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (4)
As of 2021-04-17 09:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?