← Back to DAGDA | Support | Source: https://github.com/ambv/static-annotations/commit/72cf2d7abd071f159457bd10982ac8b405660d46
Skip to content
This repository was archived by the owner on Jun 22, 2020. It is now read-only.

Commit 72cf2d7

Browse files
author
Lukasz Langa
committed
Summarize python-dev1 discussion
1 parent e33e203 commit 72cf2d7

1 file changed

Lines changed: 55 additions & 0 deletions

File tree

‎pep-0563.rst‎

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,61 @@ helper, which could solve self-referencing classes even in the form of a
561561
class decorator. He suggested the PEP should provide this helper
562562
function in the standard library.
563563

564+
Second draft discussion on python-dev
565+
-------------------------------------
566+
567+
Discussion happened mainly in the `announcement thread <https://mail.python.org/pipermail/python-dev/2017-November/150062.html>`_,
568+
followed by a brief discussion under `Mark Shannon's post
569+
<https://mail.python.org/pipermail/python-dev/2017-November/150637.html>`_.
570+
571+
Steven D'Aprano was concerned whether it's acceptable for typos to be
572+
allowed in annotations after the change proposed by the PEP. Brett
573+
Cannon responded that type checkers and other static analyzers (like
574+
linters or programming text editors) will catch this type of error.
575+
Jukka Lehtosalo added that this situation is analogous to how names in
576+
function bodies are not resolved until the function is called.
577+
578+
A major topic of discussion was Nick Coghlan's suggestion to store
579+
annotations in "thunk form", in other words as a specialized lambda
580+
which would be able to access class-level scope (and allow for scope
581+
customization at call time). He presented a possible design for it
582+
(`indirect attribute cells
583+
<https://mail.python.org/pipermail/python-dev/2017-November/150141.html>`_).
584+
This was later seen as equivalent to "special forms" in Lisp. Guido van
585+
Rossum expressed worry that this sort of feature cannot be safely
586+
implemented in twelve weeks (i.e. in time before the Python 3.7 beta
587+
freeze).
588+
589+
After a while it became clear that the point of division between
590+
supporters of the string form vs. supporters of the thunk form is
591+
actually about whether annotations should be perceived as a general
592+
syntactic element vs. something tied to the type checking use case.
593+
594+
Finally, Guido van Rossum declared he's rejecting the thunk idea
595+
based on the fact that it would require a new building block in the
596+
interpreter. This block would be exposed in annotations, multiplying
597+
possible types of values stored in ``__annotations__`` (arbitrary
598+
objects, strings, and now thunks). Moreover, thunks aren't as
599+
introspectable as strings. Most importantly, Guido van Rossum
600+
explicitly stated interest in gradually restricting the use of
601+
annotations to static typing (with an optional runtime component).
602+
603+
Nick Coghlan got convinced to PEP 563, too, promptly beginning
604+
the mandatory bike shedding session on the name of the ``__future__``
605+
import. Many debaters agreed that ``annotations`` seems like
606+
an overly broad name for the feature name. Guido van Rossum briefly
607+
decided to call it ``string_annotations`` but then changed his mind,
608+
arguing that ``division`` is a precedent of a broad name with a clear
609+
meaning.
610+
611+
The final improvement to the PEP suggested in the discussion by Mark
612+
Shannon was the rejection of the temptation to pass string literals
613+
through to ``__annotations__`` verbatim.
614+
615+
A side-thread of discussion started around the runtime penalty of
616+
static typing, with topic like the import time of the ``typing``
617+
module (which is comparable to ``re`` without dependencies, and
618+
three times as heavy as ``re`` when counting dependencies).
564619

565620
Acknowledgements
566621
================

0 commit comments

Comments
 (0)