[Python-ideas] Delay evaluation of annotations

David Mertz mertz at gnosis.cx
Thu Sep 22 15:02:14 EDT 2016


On Thu, Sep 22, 2016 at 11:42 AM, Steven D'Aprano <steve at pearwood.info>
wrote:

> > This makes it necessary to use string representation for names
> > that are not yet bound, which affects almost every class definition.
>
> Almost every class? Really? I find that implausible. Still, I can see it
> affecting *many* class definitions, so let's not quibble.
>

I would say this affects a "rare class here and there."  Almost all typing
will be with things defined in the `typing` module (or built-ins).  I guess
once in a while we'll see e.g.  `Sequence[CustomThing]`, but it will be
uncommon for that typing involving `CutomThing` to be within CustomThing
itself (well, unless you use much more recursion than Python encourages).


> -1 on complicating the simple Python model that expressions are
> evaluated when they are reached.
>

I think there is a decent argument for a more general concept of macros, or
symbols, or simpler delayed evaluation than lambda for Python in general.
I see places where this would be very nice for Pandas, for example, and for
Dask (I work with the developers of both of those projects).

In such a hypothetical future world we might come to allow, e.g.
`Sequence[#CustomThing]` where some general lazy facility or indirection is
indicated by the '#' (just a placeholder for this comment, not a
proposal).  But if that comes about, it should be available everywhere, not
only in annotations.


-- 
Keeping medicines from the bloodstreams of the sick; food
from the bellies of the hungry; books from the hands of the
uneducated; technology from the underdeveloped; and putting
advocates of freedom in prisons.  Intellectual property is
to the 21st century what the slave trade was to the 16th.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20160922/863b7d55/attachment.html>


More information about the Python-ideas mailing list