[Israel.pm] Returning a copy of an object

Yossi Itzkovich Yossi.Itzkovich at ecitele.com
Thu Jun 7 12:23:27 PDT 2007


 Hi,

In Storable documentation I found a reference to Clone module, which
should be faster but less flexible. It's OK for me.
In my case, there were 57,000 calls to my method. Using Data::Dumper
+eval took  328+328=656 sec, while using Clone::clone took only 85 sec !
Big winner !

BTW: Since it may be too much time for me even now, I guess I will
replace at least part of the calls to a new method that will not copy
the object - just will return a reference to the original one. I will
use this method for internal use.


Thank you all for your help.

Yossi

-----Original Message-----
From: perl-bounces at perl.org.il [mailto:perl-bounces at perl.org.il] On
Behalf Of Ephraim Dan
Sent: Thursday, June 07, 2007 2:33 PM
To: Perl in Israel
Subject: Re: [Israel.pm] Returning a copy of an object

> Yossi wrote:
> Is there a simple && fast way to return a copy (deep copy !) of the
original object ?

Have a look at Storable's dclone() method - look into the CODE
REFERENCES section, which I presume you'll need

Haven't benchmarked it myself, but I would expect it to be muchly much
faster than Data::Dumper

Let us know what you find

--edan

_______________________________________________
Perl mailing list
Perl at perl.org.il
http://perl.org.il/mailman/listinfo/perl




More information about the Perl mailing list