<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Fiza Sheikh</title>
    <description>The latest articles on DEV Community by Fiza Sheikh (@fiza_sheikh_d26e7da257102).</description>
    <link>https://dev.to/fiza_sheikh_d26e7da257102</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4076574%2F92d02e9d-f2c8-488d-9643-48d79bebd2a5.png</url>
      <title>DEV Community: Fiza Sheikh</title>
      <link>https://dev.to/fiza_sheikh_d26e7da257102</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/fiza_sheikh_d26e7da257102"/>
    <language>en</language>
    <item>
      <title>Port Mortem 2026 · ported pylev Python Rust · 250k diff tests, 0 mismatches · the Unicode indexing trap is real</title>
      <dc:creator>Fiza Sheikh</dc:creator>
      <pubDate>Thu, 13 Aug 2026 16:39:51 +0000</pubDate>
      <link>https://dev.to/fiza_sheikh_d26e7da257102/port-mortem-2026-ported-pylev-python-rust-250k-diff-tests-0-mismatches-the-unicode-indexing-4dm3</link>
      <guid>https://dev.to/fiza_sheikh_d26e7da257102/port-mortem-2026-ported-pylev-python-rust-250k-diff-tests-0-mismatches-the-unicode-indexing-4dm3</guid>
      <description>&lt;p&gt;&lt;strong&gt;Port Mortem Write-Up&lt;/strong&gt;: Python pylev → Rust&lt;/p&gt;

&lt;p&gt;Here's what actually happened when I picked the smallest repo on the list.&lt;/p&gt;

&lt;p&gt;Hey, I'm Fiza. Repo: &lt;a href="https://github.com/Fiza26u12/pylev-rs" rel="noopener noreferrer"&gt;https://github.com/Fiza26u12/pylev-rs&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;What I picked and why&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Discord message was clear: "the small library you can prove beats the ambitious one you can't."&lt;/p&gt;

&lt;p&gt;Everyone else probably grabbed something that sounds impressive. I grabbed "pylev" — 300 lines, Levenshtein distance, five functions, has tests. Boring on paper. That's why I picked it.&lt;/p&gt;

&lt;p&gt;If I can't prove my port matches Python on 250,000 inputs, I don't want to be in the hackathon.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;The thing that would've failed silently&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This is the part I'd have been embarrassed about if a judge found it before I did.&lt;/p&gt;

&lt;p&gt;Python: &lt;code&gt;len("café")&lt;/code&gt; → "4"&lt;br&gt;
Rust: &lt;code&gt;"café".len()&lt;/code&gt; → "5" (bytes, not characters)&lt;/p&gt;

&lt;p&gt;Every ASCII test in the original suite passes with wrong indexing. You feel done. You're not.&lt;/p&gt;

&lt;p&gt;I had to convert to &lt;code&gt;Vec&amp;lt;char&amp;gt;&lt;/code&gt; in every function. Slower. Correct.&lt;/p&gt;

&lt;p&gt;My differential tests include &lt;code&gt;café&lt;/code&gt; vs &lt;code&gt;cafe\u0301&lt;/code&gt; (precomposed vs combining accent), CJK, emoji. All pass now. None would pass with naive byte indexing.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;This ate the most thinking time&lt;/strong&gt; — not the DP algorithm, the string model.&lt;/p&gt;



&lt;p&gt;&lt;strong&gt;What I actually built&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Six functions ported: levenshtein, classic, recursive, wf, wfi, damerau. Pure Rust. Zero &lt;code&gt;unsafe&lt;/code&gt;. No PyO3 wrapper (that would've been disqualification anyway).&lt;/p&gt;

&lt;p&gt;Hardest non-algorithm bug: "damerau row rotation". Python does &lt;code&gt;dprev, d0, d1 = d0, d1, dprev&lt;/code&gt;. Get the order wrong in Rust and &lt;code&gt;foobar&lt;/code&gt;/&lt;code&gt;foobra&lt;/code&gt; returns wrong distance. No crash. Just a wrong number. Original test caught it.&lt;/p&gt;



&lt;p&gt;** How I proved it (the part that matters)**&lt;/p&gt;

&lt;p&gt;Layer 1: Python's 22 tests pass. Rust parity tests pass.&lt;/p&gt;

&lt;p&gt;Layer 2: Python script generates 20,000 inputs, saves expected answers to a file in the repo. Rust replays them in &lt;code&gt;cargo test&lt;/code&gt;. "Judge doesn't need Python installed"&lt;/p&gt;

&lt;p&gt;Layer 3: Live run — 250,000 cases, Python vs Rust, "0 mismatches". Saved in &lt;code&gt;artifacts/differential_report.json&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Did I find bugs in the original? No. I wanted to — there's a prize for that. The library is 10+ years old and correct. I'd rather say that honestly than invent a bug.&lt;/p&gt;



&lt;p&gt;&lt;strong&gt;What broke (not code — my laptop)&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;No MSVC linker → switched to GNU Rust toolchain&lt;/li&gt;
&lt;li&gt;Windows Defender "deleted my compiled binary" mid-hackathon. Renamed it, moved build folder out of OneDrive, still flagged. Had to stop relying on CLI and use &lt;code&gt;cargo test&lt;/code&gt; only.
Git push failed because Credential Manager had wrong GitHub account (&lt;code&gt;fiza-beep&lt;/code&gt; vs &lt;code&gt;Fiza26u12&lt;/code&gt;)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The port worked. The environment fought me.&lt;/p&gt;



&lt;p&gt;&lt;strong&gt;Benchmarks (honest)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;~47-83x faster on iterative algorithms on my laptop. Recursive only ~11x because both sides use hash maps.&lt;/p&gt;

&lt;p&gt;I wanted to use Criterion. Couldn't — GNU toolchain on Windows needed &lt;code&gt;dlltool.exe&lt;/code&gt; I didn't have. Hand-rolled timing instead. Numbers are directionally right, not lab-grade.&lt;/p&gt;

&lt;p&gt;Both versions allocate per call. A faster Rust version would need a different API. I chose correctness.&lt;/p&gt;



&lt;p&gt;&lt;strong&gt;What I'd take back&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Generate committed test vectors on day one. I spent time on a CLI diff harness that Defender eventually killed. The vectors in the repo are what actually prove the port. Everything else is optional.&lt;/p&gt;

&lt;p&gt;Also: read about Unicode before writing line one of Rust code. Would've saved hours of second-guessing.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fq6tdebpfqxla1c3svtnx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fq6tdebpfqxla1c3svtnx.png" alt=" " width="800" height="580"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
## Verify it yourself

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;br&gt;
bash&lt;br&gt;
git clone &lt;a href="https://github.com/Fiza26u12/pylev-rs" rel="noopener noreferrer"&gt;https://github.com/Fiza26u12/pylev-rs&lt;/a&gt;&lt;br&gt;
cd pylev-rs&lt;br&gt;
cargo test&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;


20,000 Python-generated checks, no Python needed.

Original: https://github.com/toastdriven/pylev

---

**Port Mortem 2026 · Hackathon Raptors**
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

</description>
    </item>
  </channel>
</rss>
