Porting a Python PEG parser to Rust in 72 hours, and actually proving it worked
There's a joke that every Rust project starts with someone saying "we should rewrite this in Rust" and ends four weekends later with a half-finished repo and a lot of new opinions about lifetimes. We had 72 hours. So we skipped the opinions. This is the story of rs-parsimonious — a complete Rust port of erikrose/parsimonious , a pure-Python PEG packrat parser — built for Port Mortem 2026 , a…
A team of developers aimed to rewrite a pure-Python PEG parser called parsimonious in Rust for a hackathon called Port Mortem 2026, with the goal of proving the port's effectiveness rather than just creating a half-finished project. They skipped the usual debates about opinions and stuck to the facts. The key to their success was the simplicity of a PEG parser's interface, which only requires a grammar and input to produce a parse tree or an error.
This simplicity made proving the parser's effectiveness trivial. They also confirmed that no one had already ported this specific project, ensuring their work would be unique. The team designed their Rust parser around the packrat cache, which is key to the performance of their parser. They used a stable expression identity and shared subexpressions through an Arc struct, avoiding the need for deep cloning and reducing memory usage.
They also implemented interior mutability to handle recursive grammars, which allowed them to resolve rule references in place and improve performance. The team maintained the original grammar by using the fine-regex crate, which supports lookaround, and kept the upstream grammar intact. They also optimized the parser's performance by using a release profile, enabling link-time optimization, using zero-copy where possible, and tuning the parser for release.
The result was a Rust parser that was 23 times faster than the original Python parser, used 6.7 MB of memory compared to 13 MB, and had a peak latency of just 0.016 ms.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — it may contain errors, so check the original before relying on it.