[Python-ideas] Delay evaluation of annotations

Nick Coghlan ncoghlan at gmail.com
Tue Sep 27 10:57:53 EDT 2016


On 27 September 2016 at 22:46, Neil Girdhar <mistersheik at gmail.com> wrote:
> Yes, I understand that, but I don't see how that would help at all with
> annotations.  Aren't annotations also evaluated at "compile time"?

This thread isn't about circular references in general, just circular
references in the context of type hinting.

For type hinting purposes, it already doesn't matter whether you use a
variable name to refer to a type or a quoted string literal, as the
typechecker ignores the quotation marks (and this is mandated by PEP
484).

For runtime annotation use, the difference is visible, but the only
required runtime behaviours for the typechecking use case are "doesn't
throw an exception" and "doesn't take a prohibitive amount of time to
evaluate when the function is defined".

Cheers,
Nick.

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


More information about the Python-ideas mailing list