Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Clone - clone Vs Storable - dclone

by pg (Canon)
on Mar 25, 2003 at 03:31 UTC ( [id://245605]=note: print w/replies, xml ) Need Help??


in reply to Clone - clone Vs Storable - dclone

For now, seems that you have to settle on Storable, as there are quite a few serious bugs in Clone.

However for long term, it seems Clone would replace Storable, so expect to migrate to Clone:
  1. Although Storable is also optmized, but its dclone is slower when compare to Clone's clone. This is easy to understand, as dclone is not the focus of Storable.
  2. The dclone function in Storable is kind of quick-and-dirty solution, it simply serialize the data structure first, and then deserialize it to create the clone. Although it is optimized to share data between step one and two, it still does lots of things that are needed for serialization but not pure cloning.

    The functionality of deep clone should stay in a seperate class.

Replies are listed 'Best First'.
Re2: Clone - clone Vs Storable - dclone
by UnderMine (Friar) on Mar 25, 2003 at 11:40 UTC
    I think that at the heart here we have a core vs non-core issue.

    Core modules should be upto date with the latest things that have happened

    Core modules that cause seg faults tend to get fixed fast where as when a module such as Clone causes one it is not considered such an issue.

    perl -e 'use Clone qw(clone); $a = \$b; undef $a; $c = clone $a;'
    and
    perl -e 'use Clone qw(clone); $a ={}; undef $a; $c = clone $a;'
    Cause Seg faults

    but

    perl -e 'use Clone qw(clone); undef $a; $c = clone $a;'
    and
    perl -e 'use Clone qw(clone); $a =""; undef $a; $c = clone $a;'
    does not cause this issue.

    Core supports Uni-code but it takes time for modules to catch up. It appears that Clone does not support Unicode structures correctly :-

    perl -MClone=clone -le '%a=(chr 256 =>1);$c=clone \%a; print ord fore +ach keys %$c' 196
    as oposed to
    perl -MStorable=dclone -le '%a=(chr 256 =>1);$c=dclone \%a; print ord + foreach keys %$c' 256
    Hope this clears up a few things
    UnderMine

      I believe either Clone will become a core module, or something else fullfil the clone functionality will. From an architecture point of view, it does not make sense to mix serialization and deep clone in one class.

Re^2: Clone - clone Vs Storable - dclone
by Anonymous Monk on Nov 25, 2010 at 18:49 UTC
    (1.) is not entirely true. I did test 3-level hash with approximately 20 keys per level. I did try to clone the whole thing, only two level slice and finally 1 level leaf. here are results: 1level "leaf" hash: Clone is twice as fast as dclone 2level hash: dclone is a slightly faster (assume the same) whole 3level hash: both are nearly the same (very slight ~1% advantage to Clone) everyone can setup own test but I think Clone has slight advantage only for very small structures. I would go with dclone. my 2c :) good luck!

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (2)
As of 2024-04-19 20:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found