[Python-ideas] Delay evaluation of annotations

Nick Coghlan ncoghlan at gmail.com
Fri Sep 23 12:38:05 EDT 2016


On 23 September 2016 at 20:31, אלעזר <elazarg at gmail.com> wrote:
> On Fri, Sep 23, 2016 at 6:24 AM Nick Coghlan <ncoghlan at gmail.com> wrote:
>> It's not a substitute for something like click or argparse when it
>> comes to more complex argument parsing, but it's a good example of the
>> kind of simple pseudo-DSL folks have long been able to create with
>> annotations independently of the type hinting use case.
>>
>
> That's a very nice use, and I was wrong - I did know it; I've found it not
> long ago when I wanted to implement it myself...
>
> And guess what? It does not require eager evaluation _at all_. No
> decorator-helped-annotation mechanism require eager evaluation built into
> the language. Lazy evaluation is more general than eager, in that it can
> always be forced (and not the other way around).

The problem it poses for your proposal isn't that a library like
begins couldn't be updated to work with lazy annotations (as you say,
it clearly could be), it's that it demonstrates the idea of switching
to lazy annotations involves a language level *compatibility break*
for a feature that has been around and in use for almost 8 years now,
and those need incredibly strong justifications.

While I personally have some sympathy for the perspective that using
strings for forward references in type hints feels a bit clunky, it
still doesn't come close to reaching that deliberately high bar.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia


More information about the Python-ideas mailing list