> typing features from future Python versions

I second both of these uses, but especially this (which seems to be missing 
from the original post), it’s been by far the main reason I’ve used this mode 
and I’ve seen this used, and is the main feature to look forward to when 
dropping Python 3.7 support. The new features coming to typing make static 
typing much easier, but no libraries can drop Python 3.7/3.8/3.9 support; but 
static typing doesn’t need old versions.

When talking about speed, one of the important things to consider here is the 
difference between the two proposals. PEP 649 was about the same as the current 
performance, but PEP 563 was significantly faster, since it doesn’t instantiate 
or deal with objects at all, which both the current default and PEP 563 do. You 
could even protect imports with TYPE_CHECKING with PEP 563, and further reduce 
the runtime cost of adding types - which could be seen as a reason to avoid 
adding types. To the best of my knowledge, it hasn’t been a blocker for 
packages, but something to include.

Also, one of the original points for static typing is that strings can be 
substituted for objects. “Type” is identical, from a static typing perspective, 
to Type. You can swap one for the other, and for a Python 3.6+ codebase, using 
something like “A | B” (with the quotes) is a valid way to have static types in 
3.6 that pass MyPy (though are not usable at runtime, obviously, but that’s 
often not a requirement). NumPy, for example, makes heavy usage of unions and 
other newer additions in static typing.
_______________________________________________
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/L3IKBO5YZNQ2B5Y6VA7KX352VCOCQEBB/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to