[Python-Dev] Remove typing from the stdlib

Paul Moore p.f.moore at gmail.com
Tue Nov 7 06:30:11 EST 2017


On 7 November 2017 at 10:18, Steve Holden <steve at holdenweb.com> wrote:
> On Tue, Nov 7, 2017 at 12:35 AM, Donald Stufft <donald at stufft.io> wrote:
> [..]
>
>>
>> Maybe we just need to fully flesh out the idea of a "Python Core" (What
>> exists now as “Python”) and a “Python Platform” (Python Core + A select set
>> of preinstalled libraries). Then typing can just be part of the Python
>> Platform, and gets installed as part of your typical installation, but is
>> otherwise an independent piece of code.
>>
> Given that (type and other) annotations have been promoted as an optional
> feature of the language it seems unfair and perhaps unwise to add a
> dependency specifically to support
> them
>  to the stdlib and therefore the Python core.
> Since type annotations are, as Paul pointed out, development-time features,
> it would appear to behoove those wishing to use them to separate them in
> such a way that the software can be installed without annotations, and
> therefore without the need for the typing module. Assuming they would like
> to see the widest possible distribution, of course. For selected audiences I
> am sure typing will be de rigeur,

>From my point of view, I take the same premise and come to the
opposite conclusion.

Because type annotations are a development-time feature, they should
*not* require a dependency in the final deployment (apart from Python
itself). However, because they are a language syntax feature they are
of necessity written in the application source. And type specification
of anything more complex than basic types (for example, List[int])
requires classes defined in the typing module. Therefore, typing must
be in the stdlib so that use of type annotations by the developer
doesn't impose a runtime dependency on the end user.

If there were a way of including type annotations that had no runtime
effect on the final deployed program, things would be different. But
the decision to make annotations part of the language syntax precludes
that. In particular, "it would appear to behoove those wishing to use
them to separate them" - there's no way of doing that *precisely*
because they are a language syntax feature.

Paul


More information about the Python-Dev mailing list