Meta Open-Sources Pyrefly, a High-Performance Python Type Checker in Rust
Briefly

Meta engineers have introduced Pyrefly, a high-performance, open-source Python type checker built in Rust. Aimed at replacing the previous OCaml-based Pyre type checker for Instagram, Pyrefly responds to growing complexities in type systems while supporting real-time type checking in IDEs. With impressive benchmarks showing capability to typecheck 1.8 million lines of code per second, Pyrefly outperforms its predecessor Pyre significantly. Additionally, it can infer types for unannotated code, enhancing development efficiency across various Python projects.
We explored alternate solutions and leveraged community tools like Pyright for code navigation. But the need for an extensible type checker that can bring code navigation, checking at scale, and exporting types to other services drove us to start over, creating Pyrefly.
Meta's benchmarks show that Pyrefly can typecheck the entire Instagram codebase in 13.4 seconds, compared to 100+ seconds with Pyre. Similarly, Pyrefly takes just 2.4 seconds to typecheck PyTorch, while Pyright takes 35.2 seconds and MyPy 48.1 seconds.
Read at InfoQ
[
|
]