[Python-Dev] Remove typing from the stdlib

Brett Cannon brett at python.org
Tue Nov 7 12:39:22 EST 2017


On Tue, 7 Nov 2017 at 03:34 Paul Moore <p.f.moore at gmail.com> wrote:

> 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.
>

That's not *necessarily* true if Lukasz's PEP lands and annotations become
strings. The dependency would only need to be installed if someone chose to
introspect the annotations and then "instantiate" them into actual objects.
And that only comes up if someone does it from outside by a 3rd-party, who
would then need to install the type annotation dependencies themselves.

I fully admit that could get messy if introspection from 3rd-parties
happens at all regularly and trying to manage that kind of situation. In
this instance I would argue that any code that is to facilitate creating an
object from an annotation exist outside of the stdlib if 'typing' gets
removed to prevent this sort of situation without the user of such code
being fully aware of what they are up against.

-Brett


>
> 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
> _______________________________________________
> Python-Dev mailing list
> Python-Dev at python.org
> https://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe:
> https://mail.python.org/mailman/options/python-dev/brett%40python.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20171107/9dcb670e/attachment.html>


More information about the Python-Dev mailing list