3 ms·
> Came here to mention MyPy and optional typing, the preferable term Gradual Typing means something distinctly different. Are you sure that gradual typing is d
by tedmiston 9y ago
> Came here to mention MyPy and optional typing, the preferable term Gradual Typing means something distinctly different.
Are you sure that gradual typing is different than what Mypy supports?
The Wikipedia page for gradual typing cites mypy as an example.
https://en.wikipedia.org/wiki/Gradual_typing https://en.wikipedia.org/wiki/Gradual_typing
The Mypy docstrings specifically state:
> Mypy has a powerful type system with
features such as type inference, gradual typing, generics and union
types.
https://github.com/python/mypy/blob/272d0c4c50918a36b57e7c0cc85c8cc6306ca72c/setup.py#L34 https://github.com/python/mypy/blob/272d0c4c50918a36b57e7c0c...
The section on gradual typing in PEP 483 seems consistent with this as well.
https://www.python.org/dev/peps/pep-0483/#summary-of-gradual-typing https://www.python.org/dev/peps/pep-0483/#summary-of-gradual...
- sitkack 9y agoDo they really insert extra dynamic checks? Is Sound Gradual Typing Dead? https://news.ycombinator.com/item?id=11041272 https://news.ycombinator.com/item?id=11041272 http://prl.ccs.neu.edu/gtp/research.html http://prl.ccs.neu.edu/gtp/research.html It was my understanding that MyPy was purely compile time with no runtime checks. But I could be wrong. Gradual Typing as implemented in the original paper would lead to much much slower code. The weight of a static language bolted onto a dynamic runtime for the worst of both possible worlds. Sufficiently abstract Python code is almost un-typable. I think eventually we will get there, where one can explore a program in a dynamic language and ship a correctly statically typed one. Types are only the beginning.
- tedmiston 9y agoI believe you're right that Mypy only offers compile time type checking, but not runtime. It looks like there are some active projects for runtime type checking in Python and while I don't believe Mypy is related to any of them, enforce [1] looks to also use the same standard type hinting syntax from PEP 484. [1]: https://github.com/RussBaz/enforce https://github.com/RussBaz/enforce