type hinting backward compatibility with python 3.0 to 3.4

Gregory Ewing greg.ewing at canterbury.ac.nz
Sun May 21 01:30:53 EDT 2017


Chris Angelico wrote:
> But since Python _does_ work with dynamic evaluation
> (which consequently demands that these kinds of things be expressions
> evaluated at compile time), it must by definition be possible to have
> side effects.

In most languages, type declarations are not expressions
and aren't evaluated at all in the usual sense, so questions
of evaluation order and side effects just don't apply.

If we were designing a static typing system for Python from
scratch, I would be strongly arguing that type hints shouldn't
be expressions evaluated at run time, because it's such a
poor fit for the intended use. Introspectable by all means,
but evaluated by default, no.

-- 
Greg



More information about the Python-list mailing list