Microsoft has launched an open source static-type-checking system for Python, called Pyright, that assures faster type checking for Python than other similar projects, without requiring existing Python runtime.

Pyright is designed to be used as a Visual Studio Code plugin, written in TypeScript and runs on Node.js, though it can also run as a standalone command-line tool.

According to Microsoft, Pyright is “typically 5X faster” than other Python type checkers which are mostly written in Python itself, such as Pyre, Mypy, and Pytype. And the performance of these other tools aren’t quite efficient as it depends on the systems behind it and the individual code bases. While the actual writing of these tools in Python may be convenient, but they can't run any faster than Python itself, and Python’s runtime by default doesn’t emphasize speed performance.

Albeit, Pyright relies on Python’s own type stub information to perform its analyses, so as to be able to be kept in sync with Python even though it isn’t written in the programming language, as type-checking systems for Python are for the sake of ensuring a program’s runtime correctness, not for speeding up Python applications.

It supports all the major type-related syntax currently available in Python—type hints, even variable notation syntax, and structural subtyping; also in many circumstances, supports type inference.

Pyright offers slightly above what Microsoft’s Python Language Server brings to the table, though the main focus is type checking.

The project, however is still a work in progress, with some features as yet unfinished, including: type inference for generators or validation for async/await declarations. But whether the program will be able to compile type-annotated Python to a more performant language, for example, compiling type-annotated Python to C, remains to be seen.

Microsoft launches Pyright, an open source static-type-checking system for Python



Microsoft has launched an open source static-type-checking system for Python, called Pyright, that assures faster type checking for Python than other similar projects, without requiring existing Python runtime.

Pyright is designed to be used as a Visual Studio Code plugin, written in TypeScript and runs on Node.js, though it can also run as a standalone command-line tool.

According to Microsoft, Pyright is “typically 5X faster” than other Python type checkers which are mostly written in Python itself, such as Pyre, Mypy, and Pytype. And the performance of these other tools aren’t quite efficient as it depends on the systems behind it and the individual code bases. While the actual writing of these tools in Python may be convenient, but they can't run any faster than Python itself, and Python’s runtime by default doesn’t emphasize speed performance.

Albeit, Pyright relies on Python’s own type stub information to perform its analyses, so as to be able to be kept in sync with Python even though it isn’t written in the programming language, as type-checking systems for Python are for the sake of ensuring a program’s runtime correctness, not for speeding up Python applications.

It supports all the major type-related syntax currently available in Python—type hints, even variable notation syntax, and structural subtyping; also in many circumstances, supports type inference.

Pyright offers slightly above what Microsoft’s Python Language Server brings to the table, though the main focus is type checking.

The project, however is still a work in progress, with some features as yet unfinished, including: type inference for generators or validation for async/await declarations. But whether the program will be able to compile type-annotated Python to a more performant language, for example, compiling type-annotated Python to C, remains to be seen.

No comments