Google Adopts Pyrefly for Faster, More Accurate Python Type Checking

Google has replaced its long standing Python type checker, Pytype, with Pyrefly, an open source tool originally developed by Meta. The decision was driven by Pyrefly's advantages, including faster and more accurate type checking, and lower infrastructure costs. By Sergio De Simone

Sergio De Simone ۲ دقیقه مطالعهمتن اصلی

Google has replaced its long-standing Python type checker, Pytype, with Pyrefly, an open-source tool originally developed by Meta. The decision was driven by Pyrefly's advantages, including faster and more accurate type checking, and lower infrastructure costs.

As Python’s typing system evolved rapidly, Pytype faced fundamental challenges. Because it operated by analyzing compiled bytecode rather than source ASTs, keeping pace with modern typing PEPs became an increasing maintenance burden due to bytecode instability across Python releases.

According to Google’s internal benchmarks, Pyrefly is approximately 10 times faster than Pytype, reduces incremental rebuild latency by up to 98%, and cuts peak compute cost for Python type checking by more than 80%. Google also reported a 90–99% reduction in type-checking time along clean-build critical paths, substantially "eliminating a long-standing development bottleneck".

One of Pyrefly's key strengths, Google explains, is its strong conformance to Python's typing specification, passing approximately 97% of tests in the conformance suite. Pyrefly is also actively supported by the community, which helps it keep pace with new syntax, and its diagnostics provides more actionable feedback, including inline code annotations that pinpoint the root cause of errors and, in some cases, suggest fixes.

The community has responded with interest to Google's announcement. While most commenters agreed that Pytype performs worse than Pyrefly, others debated Pyrefly's relative merits compared with Ty and Mypy. Gushys noted that

Pyrefly is much more mature. Its already at past 1.0, has similar performance speed to ty, and is a proven tool. ty just isn't quite there yet.

WindHawkeye observed that "Mypy is much faster in large setups than people think. It still has the fastest incremental type check", to which BeamMeUpBiscotti replied that

Mypy 2.0 is supposed to be up to 5x faster on large projects for cold checks, but the newer generation of type checkers can be up to an order of magnitude faster than even that.

Commenting on the announcement on LinkedIn, Python developer Amirrea Azadmher offered a different perspective, arguing that a type-checker's value is not is not merely in saving 30 seconds in CI pipelines, but in how it improves the edit-check loop during development. He also noted that:

If you're evaluating Pyright vs Pyrefly vs mypy right now, don't trust someone else's monorepo numbers. Measure cold and warm times on YOUR tree, and score diagnostics quality beside throughput — a fast checker that floods you with noise still costs more than a slower one that points at the real break.

Meta open-sourced Pyrefly last year. Pyrefly is designed for high performance and implemented in Rust to maximize efficiency. According to Meta, it can check 1.8 million lines of code per second on large codebases, making it possible to perform typechecking on every single keystroke.

I

منتشرشده در

InfoQ

خواندن در منبع

ادامه مطالعه