[Israel.pm] Returning a copy of an object
semuelf at 012.net.il
Thu Jun 7 13:23:41 PDT 2007
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.
More information about the Perl