Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Dumpxs in Data::Dumper

by kiruthika.bkite (Scribe)
on Apr 01, 2010 at 10:31 UTC ( #832276=perlquestion: print w/ replies, xml ) Need Help??
kiruthika.bkite has asked for the wisdom of the Perl Monks concerning the following question:

Hi all,

I have gone through the source code Data::Dumper.
In this source code I didn't understand about Dumpxs.
In cpan I read about this in that I read that Dumpxs is faster than Dump,but I didn't understand about this.
What is the use of it ?
Kindly explain me about this.

Thanks in advance...

Comment on Dumpxs in Data::Dumper
Re: Dumpxs in Data::Dumper
by syphilis (Canon) on Apr 01, 2010 at 11:00 UTC
    When you call Dump() it will automatically call Dumpxs() unless certain conditions exist. You can see those conditions in the Dump() source code.

    If any of those "certain conditions" *do* exist, then Dumpperl() gets called instead of Dumpxs() - because Dumpperl() can handle those conditions whereas Dumpxs() cannot.

    Dumpxs() is deemed preferable as the code for it is written in C, and it's therefore faster than the pure perl Dumpperl() implementation.

    Dump() is the only function you call, and it takes care of all of this automatically for you. To help guide you, the documentation specifies the conditions that will determine whether Dump() calls Dumpxs() or Dumpperl().

    Cheers,
    Rob
Re: Dumpxs in Data::Dumper
by Khen1950fx (Canon) on Apr 02, 2010 at 00:57 UTC
    After googling this for a couple of hours, it seems that Dumpxs should be used in situations where you have massive amounts of data to process. It's more graphically concise than Dumper. I threw together two examples---they don't use massive amounts of data:). The 1st script uses Dumper, and the 2nd script uses Dumpxs. You'll notice the difference:
    #!/usr/bin/perl use strict; use warnings; use Devel::DumpSizes qw/dump_sizes/; use Data::Dumper; my $path = system('find /usr/bin/*pdf'); &Devel::DumpSizes::dump_sizes($path); my $d = Data::Dumper->new([$path]); print Dumper $d;
    #!/usr/bin/perl use strict; use warnings; use Devel::DumpSizes qw/dump_sizes/; use Data::Dumper; my $path = system('find /usr/bin/*pdf'); &Devel::DumpSizes::dump_sizes($path); my $d = Data::Dumper->new([$path]); print $d->Dumpxs;

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://832276]
Approved by marto
Front-paged by toolic
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (16)
As of 2014-07-31 19:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (252 votes), past polls