YAML::PP ♥ libyaml

I wrote two new modules, combining YAML::PP and libyaml: YAML::LibYAML::API and YAML::PP::LibYAML


On yaml.org you can find a quite outdated, incomplete, but still interesting history of YAML.

In April 2006 Kirill Simonov released PyYAML for Python. Only few months later, he ported it to C. libyaml was born. It was supported by the Python Software Foundation as part of the Google Summer of Code.

Since then, it was ported to many other languages, or bindings to the C library were written.


In 2007, Ingy döt Net created YAML::LibYAML, better known as YAML::XS. It combines a perl binding for the libyaml event API and XS code to create data structure from the events.

It's very fast. The schema it uses for loading and dumping data (and objects) is fixed; the only thing you can disable/enable is the loading of objects.

It reads only a subset of the YAML 1.1 tag system. For example, it reads only true and false as booleans, ignoring other variants like TRUE, True, yes, y etc.


You might have heard about YAML::PP which contains modules for all four main parts of the process: parsing, constructing, representing, emitting.

These parts are all not finished yet.

But you can already use alternative parsers and emitters. Why not write one?


I started a wrapper around libyaml called YAML::LibYAML::API. It's still very new and my first real XS module, so expect bugs and changes.

It can parse YAML to a list of events and can emit YAML from a list of events.

It cannot build a perl data structure from the events. But that's what we have YAML::PP for!


YAML::PP::LibYAML has a parser and emitter. It's a subclass of YAML::PP, and it will create the object with its own parser/emitter as default. The parser gets the events from YAML::LibYAML::API and then passes them to the regular YAML::PP::Constructor. The other way around for the emitter.

Current benchmarks for parsing show the following: YAML::PP::LibYAML is 8-9 times faster then YAML::PP, both for small and large input. On the other hand, YAML::XS is 8-9 times faster than YAML::PP::LibYAML.

Have fun trying it out and please report bugs. I think unicode handling is not working correctly yet.

Leave a comment

About tinita

user-pic just another perl punk,