>
> Date: Tue, 13 Apr 2021 19:55:38 -0400
> From: Ned Batchelder <n...@nedbatchelder.com>
>
> In another message, you alluded to PEP 649 being a solution to run-time
> type checking.  Maybe I'm misunderstanding something: type annotations
> never do type checking at runtime.  As I understand it, PEP 649 is about
> avoiding the overhead of evaluating the type expression itself, not
> about checking the types of values.

Yes, and I see that as a problem. Here are two versions of code
V1
     # Apocalypse may occur if foo is not <complicated-type>
    foo = "coconut"
V2
     # Apocalypse may occur if foo is not <complicated-type>
     foo : <complicated-type> = "coconut"

To the Python interpreter both have the same semantics and runtime
behaviour. But V2 has type annotations, which are effectively
syntactically constrained comments within individual statements. As
code they do absolutely nothing. However, the performance hit from
just being present is so great that talented programmers are working
hard to make the Python interpreter ... ignore them more efficiently.

-- 

        cheers,
        Hugh Fisher
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/A24AW5W2O5OEMFYZNIWWHZVDWM7HCJKV/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to