4 ms·
Type hints don't help performance either because the interpreter discards them. The hints are not enforced by CPython, so you now need a build tool instead of j
by zelly 6y ago
Type hints don't help performance either because the interpreter discards them. The hints are not enforced by CPython, so you now need a build tool instead of just running the script. The whole point of PEP 484 seems to be to enable autocomplete in Visual Studio Code.
- dragonwriter 6y ago> The whole point of PEP 484 seems to be to enable autocomplete in Visual Studio Code. It's to enable tooling, but not just autocomplete. The main purpose of typing is preventing type-related bugs, though making editor autocompletion and other editor information more robust is a not-insignificant additional benefit. PEP 484 (created 29-Sep-2014, accepted 22-May-2015) wasn't motivated by VS Code (announced April 29, 2015).
- ivalm 6y agoYour code should get type checked whenever you run tests and can help reveal subtle bugs (for example, allowing Optional but not handling None in all code paths)
- mkesper 6y agoAnother great value of running mypy on your code is that you ensure it can be compiled as a whole!
- chasontherobot 6y agoIt has nothing to do with any particular editor, it is for autocomplete and build time type checking in any editor and type checking in people's build chains.
- BozeWolf 6y agoPyCharm understands type hints for years now. Without using mypy btw. VSCode should be able to that, there should be one or more (either finished or half baked) plugins for it. Edit: Microsoft Python Language Server has it (i read)
- josefx 6y ago> Type hints don't help performance either because the interpreter discards them. With CPython they don't. Cython actually uses annotations to optimize the generated code.
- zelly 6y agoThat's literally a different language though, but I get your point. CPython is the worst implementation.