What does the DumpXS in Perl's Data::Dumper do?
Asked Answered
W

3

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.

Whitefaced answered 1/4, 2010 at 7:4 Comment(0)
T
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.

Tragus answered 1/4, 2010 at 8:15 Comment(0)
S
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.

Sot answered 1/4, 2010 at 7:22 Comment(2)
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.Tymes
I think it's the questioner's curiosity rather than a problem with the module.Sot
S
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.

Shorttempered answered 1/4, 2010 at 7:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.