C
ChaoBro

Facebook's Pyrefly: A Rust-built Python type checker — how much faster than mypy?

Facebook's Pyrefly: A Rust-built Python type checker — how much faster than mypy?

Mypy has been around for years, and we've all gotten used to its speed — or rather, we've gotten used to how slow it is.

Meta's engineers clearly decided enough was enough. They built Pyrefly, a Python type checker and language server written entirely in Rust. Currently at 6.3K stars with 13,234 commits, the community activity looks solid.

Why Rust

This isn't a new idea. Ruff rewrote the Python linter in Rust and got a 10-50x speedup. UV took over Python package management. Now type checkers are following the same path.

Pyrefly's core selling point is straightforward: speed. Rust means no Python interpreter overhead — type inference and checking logic compile directly to machine code. For large codebases, waiting dozens of seconds for every mypy run in CI is genuinely painful.

Meta has massive internal Python codebases. They didn't build this for fun. Instagram's server side runs heavily on Python — every minute saved in type checking adds up across hundreds of engineers.

How it compares

Pyrefly targets mypy and pyright, the two mainstream options.

Mypy is the de facto standard for Python type checking — most mature ecosystem, but speed has always been a pain point. Pyright is Microsoft's TypeScript-based checker, best integrated with VS Code, faster than mypy but not dramatically so.

Pyrefly's README doesn't publish specific benchmark numbers — which is a shame. Following the Rust rewrite convention, the speedup should be in the 5-50x range depending on codebase size and type complexity.

My take: don't rush to migrate. Pyrefly is still in active development — 459 open issues, 128 PRs in the queue. That means rapid iteration, but also that stability and compatibility aren't production-grade yet.

Can you use it today

If you're running mypy on your projects and occasionally find it slow, Pyrefly isn't ready to replace it yet. Its type system coverage still trails mypy, especially on edge cases — generics, protocols, type guards.

But if your team is large, your codebase exceeds a million lines, and type checking has become a CI bottleneck — worth watching closely. Meta is already using it internally; they wouldn't gamble their production environment.

Wait for Pyrefly 1.0, benchmark data, and mypy compatibility tests to complete — then consider migration. Safer that way.

My current stance: star the repo, don't install yet. Type checkers aren't toys — the cost of picking wrong is non-trivial.

A telling detail

Pyrefly has .llms/rules in its repo, pointing agentic tools to AGENTS.md. This means Meta is designing this tool with AI coding assistants in mind from the start. A type checker isn't just for humans — it's for AI agents too. The difference between a 30-second wait and a 3-second wait matters more for an agent than for a person.

That detail matters more to me than speed numbers.


Sources: