Hasty Briefsbeta

Bilingual

Pyrefly vs. Ty: Comparing Python's Two New Rust-Based Type Checkers

a year ago
  • #Python
  • #Rust
  • #Type Checking
  • Two new Rust-based Python type checkers, pyrefly (Meta) and ty (Astral), were introduced at PyCon 2025.
  • Both tools are open-source, incremental, and powered by Ruff for AST parsing, but differ in goals and approaches.
  • Pyrefly focuses on aggressive type inference, aiming to catch as many errors as possible, even in untyped code.
  • Ty emphasizes the gradual guarantee, ensuring type annotations don't introduce errors in working code.
  • Benchmarking shows ty is 2-3x faster than pyrefly, both significantly outperforming mypy and pyright.
  • Pyrefly uses module-level incrementalization, while ty employs fine-grained incrementalization via Salsa.
  • Ty introduces innovative features like intersection and negation types, unique among Python type checkers.
  • Both tools are in early alpha, with pyrefly excelling in implicit type inference and ty in clear error messages.
  • Future developments may see convergence of features, with rumors of a Google Go-based type checker in the works.