tags:

views:

59

answers:

3

I have gone through the source code of Data::Dumper. In this package I didn't understand what's going on with DumpXS. What is the use of this DumpXS?

I have searched about this and I read that, it is equal to the Dump function and it is faster than Dump. But I didn't understand it.

+2  A: 

A lot of Perl modules have "XS" versions, like JSON::XS. The XS in the name means that it partly uses C in order to increase the speed or other efficiency of the module. I don't know this particular case, but it is probably that.

Kinopiko
It is. But that's a detail a normal Data::Dumper user shouldn't even care about. It'll use the XS (i.e. C) implementation whenever it can because it's faster.
tsee
I think it's the questioner's curiosity rather than a problem with the module.
Kinopiko
+1  A: 

And if you want a bit more info on XS go to http://perldoc.perl.org/perlxs.html But I am curious what lead you to this question.

justintime
+5  A: 

The XS language is a glue between normal Perl and C. When people want to squeeze every last bit of performance out of an operation, they try to write it as close to the C code as possible. Python and Ruby have similar mechanisms for the same reason.

Some Perl modules have an XS implementation to improve performance. However, you need a C compiler to install it. Not everyone is in a position to install compiled modules, so the modules also come in a "PurePerl" or "PP" version that does the same thing just a bit slower. If you don't have the XS implementation, a module such as Data::Dumper can automatically use the pure Perl implementation. In this case, Data::Dumper also lets you choose which one you want to use.

brian d foy