[Python-ideas] Delay evaluation of annotations

Stephen J. Turnbull turnbull.stephen.fw at u.tsukuba.ac.jp
Sun Sep 25 15:00:47 EDT 2016


אלעזר writes:

 > But nobody (yet) claimed it to be a reasonable example of code we
 > don't want to break.

"Reasonable example" is not the standard.  The ideal is that
*nobody*'s code breaks unless it's necessary to to fix a bug.  The
current implementation conforms to the specification[1], and therefore
the proposed change is not a bugfix.

    The Yale Book of Quotations quotes English judge Robert Megarry
    as follows:  "Whereas in England all is permitted that is not
    expressly prohibited, it has been said that in Germany all is
    prohibited unless expressly permitted and in France all is
    permitted that is expressly prohibited. In the European Common
    Market no-one knows what is permitted and it all costs more."
    http://freakonomics.com/2009/10/29/quotes-uncovered-death-and-statistics/

Python, of course, follows the principle of English law.  That's what
we mean by "consenting adults".

The rules about change are more flexible in the stdlib, but even there
we get reports every release about breakage due to improvements in
various modules.  This is the language definition, so "if you can do
it in vX.Y, it should do the same in vX.(Y+1)" is a strict rule.[2]


Footnotes: 
[1]  Assuming, as I do, that in PEP 3107 "expression" refers only to
the syntax specification and does not at all imply adding a new
expression type to the language.  What is stored in __annotations__
is thus implied to be the object that is the value of the expression,
following the precedent of initialization, and the general Pythonic
approach of evaluating expressions when encountered.  And that
semantics is stated explicitly in PEP 3107.

[2]  The definition of "do the same" does not necessarily mean
"produce identical output", eg, in the case of "dir()" in the bare
interpreter with no imports.



More information about the Python-ideas mailing list