3 ms·
Python with type annotations isnt faster using python runtime. But some packages can utilize it for higher performance but most of the time it'll be slower cau
by machinekob 5y ago
Python with type annotations isnt faster using python runtime.
But some packages can utilize it for higher performance but most of the time it'll be slower cause you need to parse extra information if you want to reuse it in pure python.
- quietbritishjim 5y agoIt's true that if your Python code is being interpreted with CPython then adding type annotations won't make it any faster. But the comment said that if you're already compiling your Python code with Cython then adding type annotations will allow Cython to make your code a little faster.
- bobbylarrybobby 5y agoYou're thinking of CPython, the standard implementation of Python. Cython is a (barely) separate language that looks a lot like Python but gets compiled to something like C. When you need performance, you can drop down from (C)Python into Cython
- machinekob 5y agoMb im blind ofc Cython would be faster :P