[Israel.pm] Returning a copy of an object

Yossi Itzkovich Yossi.Itzkovich at ecitele.com
Fri Jun 8 02:05:05 PDT 2007


It's a good idea.  Do you know of a module that does it ? I don't want
to reinvent the wheel (+bugs) .


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

Yossi Itzkovich Wrote:

>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.

Other idea: maybe you can implement a copy-on-write scheme?
Give your client a reference to a wrapper object, that will pass trough
the reading calls, and will block/alter the writing calls. Or will copy
the relevant data to itself, and perform the call on itself.
Of course, that depend on what exactly is going in your system.


Perl mailing list
Perl at perl.org.il

More information about the Perl mailing list