Is there a compiled and typed python?

You're probably aware of it already but I'll throw it into the ring for completeness: PyPy is the best-known JIT compiler for Python.

As your code runs, PyPy can generate machine-code for the parts it can optimise (and that it sees are executed often) and runs these instructions instead. The speed boost can be huge and no change to your Python code is required (assuming PyPy supports the Python features you're using).

This is not obviously not the same as compiling ahead of time. At the risk of interpreting your question too literally, it seems that such a thing is not possible using exactly Python's syntax.

The language is too flexible for this: compiling code to fast machine instructions requires the types of variables to be known and not be changed. This is why Julia requires that extra syntax. In Python, you can change almost anything about your program as the program is running, making it pretty much impossible to generate efficient machine code. (Caveat: I am not a compiler expert.)

/r/Python Thread