[Bioperl-l] $obj->clone

Tim Bunce Tim.Bunce@pobox.com
Thu, 19 Sep 2002 23:31:46 +0100


On Thu, Sep 19, 2002 at 10:50:03AM -0700, Hilmar Lapp wrote:
> They also refer to the (allegedly - not surprisingly - slower) 
> Storable::dclone -- that in fact sounds appealing to me as it's pure 
> perl, and I believe we have a dependency on Storable already.

Storable is implemented in XS/C, but it's a core module now.
It also now has a huge test suite with many correctly handled edge cases.

I'd recommend it unless the Clone module has something you really
need - like significantly more speed. Seems like Clone would be
faster because it just clones whereas Storable's dclone() is really
just $new=thaw(freeze($old)) so has the overhead of creating the
serialised form.

Tim.

> Hm... so deep-cloning (again, not surprisingly) is a solved problem 
> then ... no need to integrate this into bioperl -- or would it be 
> better to have our own clone() method in Root.pm that just delegates 
> to Storable's dclone()? We have taken this route in the past, makes 
> accommodating different platforms and perl versions easier.
> 
> 	-hilmar
> 
> On Thursday, September 19, 2002, at 09:55 AM, ecky@e-lehmann.de wrote:
> 
> >Hi,
> >
> >I had the same problem some time ago... and I found the Perl extension
> >"Clone" on CPAN.
> >On C level it copies large and nested data structures even with
> >references and references to references or Perl objects.
> >You can inherit from the module and use object oriented style or use
> >only the function clone() by "use Clone qw(clone);" as the man page
> >describes...
> >Here is the link:
> >
> >http://search.cpan.org/author/RDF/Clone-0.13/Clone.pm
> >
> >Hope it works for you...
> >
> >Eckhard
> >
> >
> >Hilmar Lapp <hlapp@gnf.org> schrieb am 18.09.2002, 22:51:54:
> >>This was on the table a while ago, I know, so it may be a dead horse
> >>I'm beating. I rather mean it as a poll what people think and
> >>whether people think life is going to be easier or unchanged w/ or
> >>w/o a clone method.
> >>
> >>The background why I resumed beating this horse is I have written
> >>some code for bioperl-db that deep-traverses objects and replaces
> >>all possible child objects. This would get me 3/4 of the way for
> >>writing up a deep-clone routine (shallow clone is 2 lines in perl).
> >>
> >>Any thoughts whether having this would be useful or rather dangerous?
> >>
> >>	-hilmar
> >>--
> >>-------------------------------------------------------------
> >>Hilmar Lapp                            email: lapp at gnf.org
> >>GNF, San Diego, Ca. 92121              phone: +1-858-812-1757
> >>-------------------------------------------------------------
> >>
> >>_______________________________________________
> >>Bioperl-l mailing list
> >>Bioperl-l@bioperl.org
> >>http://bioperl.org/mailman/listinfo/bioperl-l
> >>
> --
> -------------------------------------------------------------
> Hilmar Lapp                            email: lapp at gnf.org
> GNF, San Diego, Ca. 92121              phone: +1-858-812-1757
> -------------------------------------------------------------
> 
> _______________________________________________
> Bioperl-l mailing list
> Bioperl-l@bioperl.org
> http://bioperl.org/mailman/listinfo/bioperl-l