Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: do separate hashes share common keys?

by swl (Parson)
on Feb 14, 2021 at 06:44 UTC ( [id://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 (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

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (8)
As of 2024-04-19 15:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found