in reply to Re: Re: Making a new list of hashes from a hashref
in thread Making a new list of hashes from a hashref

Yes, pointed out, Clone is on the order of twice as fast as Storable.

In terms of the drawbacks, there have been some reports of core dumps when using Clone on some edge-case structures, although I've forgotten the details (it's certainly not common). Also, Storable provides a hook that lets objects participate in their cloning, so that the copied object can perform some kind of re-initialization or other post-cloning cleanup.

I've also posted a pure-Perl implementation to CPAN as Clone::PP, which is of course slower than either of the above.

And for those times where you don't really care how it's implemented, as long as you get a working deep-clone function, I've posted a generic facade called Clone::Any which will attempt to load Storable, Clone, or an equivalent module and will export the clone function from the first one it finds.

  • Comment on Re: Re: Re: Making a new list of hashes from a hashref

Replies are listed 'Best First'.
Re: Re: Re: Re: Making a new list of hashes from a hashref
by BrowserUk (Patriarch) on Oct 10, 2003 at 22:54 UTC

    All i can say is that I've been using Clone ever since Jeffa pointed it out to me at (jeffa) Re: Deepcopy of complex structures. and I benchmarked it at Re: Deepcopy of complex structures. (resolved) and found it to be so vastly more efficient. Since then, it's been an indispensible part of my toolkit that I use and itjust works.

    That's about as high a recommendation as I can give. I'm not shy of building deep and complex data structures, including thise that contain bless refs, and internal cross-references, and my confidence in doing so comes not in small part from the knowledge that when I need to copy them clone will "just do it", simply and efficently. I treat it like it was a built-in function and (so far) it's never let me down.

    Many thanks to you for making the module available. It gets my highest approval rating -- I use it regularly without needing to look at the documentation. It is an integral part of perl as far as I am concerned.


    Examine what is said, not who speaks.
    "Efficiency is intelligent laziness." -David Dunham
    "Think for yourself!" - Abigail