[Python-Dev] Is static typing still optional? (original) (raw)
Steve Holden steve at holdenweb.com
Tue Dec 19 12:30:45 EST 2017
- Previous message (by thread): [Python-Dev] Is static typing still optional?
- Next message (by thread): [Python-Dev] Is static typing still optional?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Tue, Dec 19, 2017 at 10:53 AM, Paul Moore <p.f.moore at gmail.com> wrote:
On 19 December 2017 at 07:49, Eric V. Smith <eric at trueblade.com> wrote: > Data Classes is also not the first use of type annotations in the stdlib: > https://docs.python.org/3/library/typing.html#typing.NamedTuple >
Also, the fact that no-one raised this issue during the whole time the PEP was being discussed (at least as far as I recollect) and that Guido (who of all of us should be most aware of what is and isn't acceptable use of annotations in the stdlib) approved the PEP, suggests to me that this isn't that big a deal. The only thing that has surprised me in this discussion is that the actual type used in the annotation makes no difference. And once someone reminded me that types are never enforced at runtime (you can call f(x: int) with f('haha')) that seemed fine.
If anything, this makes things more difficult for the learner. The fact that annotations are formally undefined as to anything but syntax is sensible but can be misleading (as the example above clearly shows).
In the typing module it's logical to see annotations, I guess. But I really hope they aren't sprinkled around willy-nilly. Sooner or later there will be significant demand for annotated libraries, even though CPython will perform exactly as it does with non-annotated code. I can see the value of annotations in other environments and for different purposes, but it would be a pity if this were to unnecessarily complicate the stdlib.
regards Steve -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20171219/eef053c1/attachment.html>
- Previous message (by thread): [Python-Dev] Is static typing still optional?
- Next message (by thread): [Python-Dev] Is static typing still optional?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]