<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom"><title>Emma's Blog - yaml</title><link href="https://emmatyping.dev/" rel="alternate"/><link href="https://emmatyping.dev/feeds/yaml/atom.xml" rel="self"/><id>https://emmatyping.dev/</id><updated>2026-03-02T00:00:00-08:00</updated><entry><title>Announcing ryaml, a drop-in compatible Python yaml parser</title><link href="https://emmatyping.dev/announcing-ryaml-a-drop-in-compatible-python-yaml-parser.html" rel="alternate"/><published>2026-03-02T00:00:00-08:00</published><updated>2026-03-02T00:00:00-08:00</updated><author><name>Emma Smith</name></author><id>tag:emmatyping.dev,2026-03-02:/announcing-ryaml-a-drop-in-compatible-python-yaml-parser.html</id><summary type="html">&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 …&lt;/p&gt;</summary><content type="html">&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;</content><category term="misc"/><category term="python"/><category term="rust"/><category term="yaml"/></entry></feed>