[Python-ideas] Fwd: Re: Delay evaluation of annotations

David Mertz mertz at gnosis.cx
Sun Sep 25 14:04:05 EDT 2016


> 1. Please consider disallowing the use of side effects of any kind in
annotations, in that it is not promised when it will happen, if at all. So
that a change 3 years from now will be somewhat less likely to break
things. Please consider doing this for version 3.6; it is feature-frozen,
but this is not (yet) a feature, and I got the feeling it is hardly
controversial.

What you are proposing is a very large and controversial feature change.
Just repeating that you think there documented 10-year old behavior is an
accident doesn't make it so.

This is ABSOLUTELY impossible for 3.6. my feeling is is probably oppose it
for 3.7, bit that is the soonest timeframe that is even conceivable.

Here's a quick, only slightly contrived, example where i want an annotation
to have a side effect:

def foo(a, b) -> logdef(): ...

This might be used as part of a tracing, cod coverage, or timing library.
Obviously it would need to do some magic to get more info about the
function being logged, bit that's possible.

And yes, I can think of other ways to achieve this effect (decorators
maybe), but you want to make change to prohibit this use that might be in
production for ten years.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20160925/10211786/attachment.html>


More information about the Python-ideas mailing list