<div dir="ltr"><div><div><div><div><div><div><div><div><div><div><div><div><div><div><div><div><div>> The difference in allocated memory is over 22 MB.<br>> The import time with
annotations is over 2s longer.<br>> The problem with those numbers that we
still have 80% functions to cover.<br><br></div>This will not be a problem with PEP 560 (I could imagine that string objects<br>may take actually more memory than relatively small cached objects).<br><br></div>Also I think it makes sense to mention in the PEP that stringifying annotations<br>does not solve _all_ problems with forward references. For example, two typical</div><div>situations are:<br><br></div>Â TÂ = TypeVar('T', bound='Factory')<br><br></div>Â class Factory:<br></div>Â Â Â Â Â def make_copy(self: T) -> T:<br>Â Â Â Â Â Â Â Â Â ...<br><br></div>and<br><br></div>Â class Vertex(List['Edge']):<br>Â Â Â Â Â ...<br></div>Â class Edge:<br></div>Â Â Â Â Â ends: Tuple[Vertex, Vertex]<br><br></div>Actually both situations can be resolved with PEP 563 if one puts<br></div>`T` after `Factory`, and `Vertex` after `Edge`, the latter is OK, but<br></div>the former would be strange. After all, it is OK to pay a _little_ price<br></div>for Python being an interpreted language.</div><div><br></div><div>There are other situations discussed in</div><div><a href="https://github.com/python/typing/issues/400">https://github.com/python/typing/issues/400</a>, I don't want to copy all</div><div>of them to the PEP, but I think this prior discussion should be referenced</div><div>in the PEP.<br></div><div><br>> This is not a viable strategy since __future__ is not designed to be<br>> a
feature toggle but rather to be a gradual introduction of an upcoming<br>> breaking change.<br><br></div>But how it was with `from __future__ import division`? What I was proposing<br></div>is something similar, just have `from __future__ import annotations` that will<br></div>be default in Python 4. (Although this time it would be a good idea to emit</div><div>DeprecationWarning one-two releases before Python 4).<br></div><div><br>--<br></div>Ivan<br><br><br></div>