A static type checker for Python and a compiler for type-annotated Python

Why mypy?

Mypy can find many classes of bugs automatically, improving the quality of your code. Perhaps more importantly, type annotations act as machine-checked documentation and make your code easier to understand and maintain. Mypy can scale to multi-million line codebases, while providing quick incremental checking through the mypy daemon.

Mypy lets you freely mix type checked and unannotated code, making it possible to gradually migrate existing codebases to static type checking.

What is mypyc?

Mypyc is a compiler from a type annotated Python dialect to CPython C extension modules that uses mypy as the front end. It can often significantly speed up Python code. We originally built mypyc to compile mypy, making mypy 4x faster. We are now looking at making mypyc useful for end users as a practical tool to make Python programs and libraries more efficient.

It's easy to ensure that programs compiled with mypyc continue to also be valid (non-compiled) Python programs. Modules compiled with mypyc can freely interact with interpreted modules. Mypyc lets you compile a few performance-sensitive modules and keep the rest of your program interpreted.

lightbulb_outline View ideas list


  • python


comment IRC Channel
mail_outline Contact email

mypy 2021 Projects

  • Pranav Rajpal
    Improve support for singledispatch
    Currently, mypy and mypyc are unable to recognize uses of the singledispatch decorator, making mypy generate false positives and mypyc generate...
  • Jingchen YE
    Speeding up string operations of Mypyc
    Mypyc is a compiler from type-annotated Python to CPython C extension modules. It uses type information and restrictions to certain dynamic language...