[Python-Dev] Type hints -- a mediocre programmer's reaction

Guido van Rossum guido at python.org
Mon Apr 20 22:07:13 CEST 2015


On Mon, Apr 20, 2015 at 12:49 PM, Paul Moore <p.f.moore at gmail.com> wrote:

>
> On 20 April 2015 at 20:35, Łukasz Langa <lukasz at langa.pl> wrote:
>
>> Since it was mentioned in a different e-mail in this thread: yes, the
>> standard library is not getting any type annotations. When we decide to
>> ship type hints with Python 3.6, they will be added as stubs.
>
>
> Why is this? Surely this is something where the stdlib should "eat its own
> dogfood" and include inline hints rather than stub files?
>

Actually, "eat your own dogfood" is not one of the goals of the stdlib --
nor is it supposed to be an example of how to code. This is often
misunderstood.  The stdlib contains a lot of Python code, and you can learn
a lot from it, but good coding habits aren't generally something you learn
there -- the code is crusty (some of the oldest Python code in existence
lives in the stdlib!), often has to bend over backwards to support backward
compatibility, and is riddled with performance hacks.

Based on some events in the distant past, there's actually an active ban
against sweeping changes to the stdlib that attempt to "modernize" it or
use new features -- because there is so much code in the stdlib, review of
such sweeping (often near-mechanical) changes is inevitably less thorough
than when a new feature is implemented, and even the best tests don't catch
everything, so regressions in dark corners are often the result.

The only place in the stdlib where I expect inline type hints to be used is
in brand new modules introduced in 3.6 or later, and then only when the
author believes inline type hints to be clearer than wordy docstrings.

The situation is possibly even bleaker (or happier, depending on your
position :-) for inline type hints in 3rd party packages -- few package
authors will be satisfied with supporting only Python 3.5 and later. True,
you can support Python 3.2 and up by declaring the 3rd party typing package
as a dependency (unless Python 3.5+ is detected), but I don't expect this
to become a popular approach overnight.

So I think the rumors of Python's death are greatly exaggerated.

-- 
--Guido van Rossum (python.org/~guido)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20150420/0eebb174/attachment-0001.html>


More information about the Python-Dev mailing list