Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

perl

xs

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.

like image 367
kiruthika Avatar asked Apr 01 '10 07:04

kiruthika


1 Answers

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.

like image 82
brian d foy Avatar answered Sep 27 '22 23:09

brian d foy