[Python-ideas] Runtime types vs static types

Chris Angelico rosuav at gmail.com
Sun Jul 2 07:38:11 EDT 2017


On Sun, Jul 2, 2017 at 9:16 PM, Steven D'Aprano <steve at pearwood.info> wrote:
> If we want to support that optimization, we could add an optimization
> flag that strips annotations at runtime, just as the -OO flag strips
> docstrings. That becomes a matter of *consenting adults* -- if you don't
> want annotations, you don't need to keep them, but it then becomes your
> responsibility that you don't try to use them. (If you do, you'll get a
> runtime AttributeError.)

IMO people should act as if this will eventually be the case.
Annotations should be evaluated solely for the purpose of populating
__annotations__, and not for any sort of side effects - just like with
assertions.

ChrisA


More information about the Python-ideas mailing list