5

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.

brian d foy
  • 129,424
  • 31
  • 207
  • 592
kiruthika
  • 2,155
  • 7
  • 26
  • 33

3 Answers3

5

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
  • 129,424
  • 31
  • 207
  • 592
2

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.

  • 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 Apr 01 '10 at 07:49
  • 1
    I think it's the questioner's curiosity rather than a problem with the module. –  Apr 01 '10 at 08:01
0

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
  • 3,601
  • 4
  • 22
  • 37