4 ms·
- You can specify types - Types are checked before run time - Type errors are reported If that's not static typing, what is?
by yawaramin 9y ago
- You can specify types
- Types are checked before run time
- Type errors are reported
If that's not static typing, what is?
- sidlls 9y agoThis argument isn't convincing. These artifacts are hints that can be ignored, not constraints to the python interpreter. It seems to me a bit like arguing that the existence of Coverity (and other static analysis tools) means C is as safe as Rust.
- yawaramin 9y agoThe types were never meant for the Python interpreter, they were meant as documentation and as input for static analysis tools. Mypy just happens to be a static typechecker that takes advantage of the type annotations. Just because mypy is optional doesn't mean it's not static typing.
- leshow 9y agoWhat is a static or strong type system is sort of up for debate, the terms are not well defined. Not OP, but IMO type annotations are static but not strong. I'd consider a strong type system one that enables you to encode additional invariants in the types, with sum and product types being perhaps the minimal requirement.
- lmm 9y agoIf Python were statically typed: - Most Python expressions and standard library functions would have (nontrivial) types - It would be unusual for a Python library to come without (nontrivial) types - It would be unusual for Python code containing type errors to be distributed - Many classes of runtime errors (e.g. no such method) would be unusual in Python code that does not contain type errors
- yawaramin 9y agoPython is not statically typed. Mypy adds a layer of static typing on top of Python.
- lmm 9y agoRight, but it's misleading to say "Python has static typing", because while an implementation of static typing in Python exists, the vast majority of the Python ecosystem doesn't use it.
- yawaramin 9y agoThat's why I didn't say 'Python has static typing', I said: > Python 3 supports type annotations natively And: > the mypy tool is an external typechecker that you can run just like any other static analysis tool I think I was pretty clear that Python is not statically typed.