<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Emma's Blog - yaml</title><link>https://emmatyping.dev/</link><description/><atom:link href="https://emmatyping.dev/feeds/yaml/rss.xml" rel="self"/><lastBuildDate>Mon, 02 Mar 2026 00:00:00 -0800</lastBuildDate><item><title>Announcing ryaml, a drop-in compatible Python yaml parser</title><link>https://emmatyping.dev/announcing-ryaml-a-drop-in-compatible-python-yaml-parser.html</link><description>&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;tl;dr&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://github.com/emmatyping/ryaml"&gt;ryaml&lt;/a&gt; is a YAML 1.1 parser that is both
drop-in compatible and faster than PyYAML. And it's written in safe Rust too!&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Four (4) years ago, I wanted to make a YAML library that was fast and memory
safe. This was originally
a &lt;a href="https://en.wiktionary.org/wiki/yak_shaving"&gt;yak shave&lt;/a&gt; for another project.
I've forgotten which project since then! The result of that work was
&lt;a href="https://github.com/emmatyping/ryaml"&gt;ryaml&lt;/a&gt;, a YAML parsing library for Python
built on top of &lt;a href="https://github.com/dtolnay/serde-yaml"&gt;serde-yaml&lt;/a&gt;, which at
the time was the go-to Rust yaml parsing library. Serde-yaml was fantastic to
use at it allowed me to create the library in a performant manner while being
very simple to implement. Together with serde-yaml I was able to use
&lt;a href="https://github.com/davidhewitt/pythonize"&gt;pythonize&lt;/a&gt; by David Hewitt (lead PyO3
maintainer) to quickly convert from YAML text to Python objects and back again.&lt;/p&gt;
&lt;p&gt;The project was successful; ryaml was incredibly fast, and used Rust to parse
scalar values like integers, strings, and floats. However, the initial version
of ryaml had issues which I felt limited it from reaching where I wanted it to
be.&lt;/p&gt;
&lt;h2&gt;Safety&lt;/h2&gt;
&lt;p&gt;Serde-yaml used &lt;a href="https://github.com/dtolnay/unsafe-libyaml"&gt;libyaml-unsafe&lt;/a&gt;,
under the hood, an unsafe Rust port of libyaml using
&lt;a href="https://c2rust.com/"&gt;c2rust&lt;/a&gt;. This was good for compatibility, (see the next
section), but meant that ryaml's core was still unsafe. Unsafe Rust has a lot of
benefits over C, but I wanted a majority of the parsing to happen in safe Rust
to minimize the chance of memory-based exploits.&lt;/p&gt;
&lt;h2&gt;Compatibility&lt;/h2&gt;
&lt;p&gt;Serde-yaml did not support all of the features in
YAML 1.1 that PyYAML does,
&lt;a href="https://github.com/dtolnay/serde-yaml/issues/91"&gt;such as binary types&lt;/a&gt;. I
wanted ryaml to be &lt;em&gt;drop-in compatible&lt;/em&gt; with PyYAML eventually. To reach that
goal would require handling a lot of extra parsing&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Emma Smith</dc:creator><pubDate>Mon, 02 Mar 2026 00:00:00 -0800</pubDate><guid>tag:emmatyping.dev,2026-03-02:/announcing-ryaml-a-drop-in-compatible-python-yaml-parser.html</guid><category>misc</category><category>python</category><category>rust</category><category>yaml</category></item></channel></rss>