3 ms·
> The typing features are optional, so much so that CPython by default doesn't do anything with them. That is true...for now. But let us look at these two PEP
by wheelerof4te 3y ago
> The typing features are optional, so much so that CPython by default doesn't do anything with them.
That is true...for now.
But let us look at these two PEPs, only:
https://peps.python.org/pep-0585/s https://peps.python.org/pep-0585/s
and
https://peps.python.org/pep-0604/ https://peps.python.org/pep-0604/
PEP 585 added new syntax for built-in collection types that doesn't work with older versions of Python.
PEP 604 also added new Union and Optional typing syntax that doesn't work with older versions of Python, either. So, you will effectively break your code if you try adding any of these. In a large enough codebase, there could be dozens of these annoying things. Why do that when you could have offloaded every single typing annotation to it's separate module (conveniently called typing), and add a simple shortcut to an IDE to have types removed/re-introduced automatically.
There are even more built-in ways to type your arguments now. So, let's see how long your argument stands.
- squeaky-clean 3y ago> So, you will effectively break your code if you try adding any of these. I don't follow, isn't this just bringing in features from a later version of the language and complaining they don't work? Pattern matching doesn't work in Python 3.9, but I wouldn't say it "effectively breaks your code" just because you try them in python3.9 You also don't have to add them, they're optional.
- wheelerof4te 3y agoIntroducing pattern matching to Python, in a minor version no less, almost created another language inside Python that you have to learn now. New typing syntax outside of the "typing" module did the same. People governing the development of Python forgot what backwards compatibility of a programming language means.
- squeaky-clean 3y agoYou don't need to learn any of those, and they don't break pre-existing code. You can run code written for Python3.2 in 3.10. You can't run code written for Python3.10 in Python3.2. That's what backwards compatibility means. It has nothing to do with new features that only affect themselves. Also Python predates SemVer, so it doesn't use major.minor.patch. 3.10 is not considered a minor update.
- qsort 3y agohttps://peps.python.org/pep-0484/ https://peps.python.org/pep-0484/ > It should also be emphasized that Python will remain a dynamically typed language, and the authors have no desire to ever make type hints mandatory, even by convention.