Perl 的 Data::Dumper 中的 DumpXS 是做什么的?
我已经浏览了 Data::Dumper 的源代码。在这个包中我不明白DumpXS是怎么回事。这个DumpXS有什么用呢?
我搜索过这个,我读到,它等于 Dump
函数,并且比 Dump
更快。但我不明白。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
XS 语言 是普通 Perl 和 C 之间的粘合剂。当人们想要榨干最后一点时为了提高操作的性能,他们尝试编写尽可能接近 C 代码的代码。出于同样的原因,Python 和 Ruby 有类似的机制。
一些 Perl 模块具有 XS 实现以提高性能。但是,您需要一个 C 编译器来安装它。不是每个人都有能力安装已编译的模块,因此这些模块也有“PurePerl”或“PP”版本,它们可以完成相同的操作,只是速度慢一点。如果您没有 XS 实现,则可以使用 Data::Dumper 之类的模块自动使用纯 Perl 实现。在这种情况下,Data::Dumper 还允许您选择要使用哪一个。
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.
许多 Perl 模块都有“XS”版本,例如 JSON::XS。名称中的 XS 意味着它部分使用 C 以提高模块的速度或其他效率。我不知道这个具体情况,但大概就是这样。
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.
如果您想了解有关 XS 的更多信息,请访问 http://perldoc.perl.org/perlxs。 html
但我很好奇是什么让你提出这个问题。
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.