

PEP 3107 – Function Annotations in Python 3 - Spittie
http://legacy.python.org/dev/peps/pep-3107/

======
jerf
Lacks compositional abilities as specified, which is unfortunate. If two
libraries want to use this at the same time for two different purposes,
there's no standard given for it.

I guess I have to admit that my feeling is that in our rich existing language
ecosystem, features that seem designed to help turn Python into something it
isn't just waste time and steps Python that much closer to Enterprise-class
complexity. Maybe what Python really needs most right now is just a straight-
up language freeze. It's done, it is what it is, what it is is pretty darned
good for a lot of use cases, and that last bit can't be highlighted enough. It
isn't going to be a static language wonder, it isn't going to have generalized
C-class performance, it isn't going to become a great hugely-concurrent
multithreading language, and you know what? That's OK. It's better to be a
good Python than to be a bad not-quite-anything.

~~~
pekk
By a language freeze, you mean that Python should never change again?

~~~
jerf
Or at least, raise the bar on changes much, much higher. Total freeze is
probably an unrealistic goal, but a at least a "conceptual" freeze, yes.

------
ak217
I've added a type checking decorator for function annotations to my assertions
helper library,
[https://github.com/kislyuk/ensure](https://github.com/kislyuk/ensure):

    
    
        from ensure import ensure_annotations
    
        @ensure_annotations
        def f(x: int, y: float) -> float:
            return x+y
    
        f(1, 2.3)
        >>> 3.3
        f(1, 2)
        >>> ensure.EnsureError: Argument y to <function f at 0x109b7c710> does not match annotation type <class 'float'>
    

It's useful sometimes.

~~~
thomasahle
How does that work? Is it abusing dictionary syntax without braces?

~~~
ak217
The PEP describes it nicely :)

I'm not a huge fan of the "->" syntax myself, but I'm not sure what would work
better.

------
unwind
OK, I'll bite: This is from [2010], so rather old.

What changed to make this relevant now?

~~~
_pmf_
> What changed to make this relevant now?

Python is increasingly losing ground to the new "it"-languages. To stay
relevant, it needs cryptic syntax of dubious value so bloggers can write
lengthy articles about useless applications for this new feature.

~~~
threatofrain
What examples do you have (Go?), and do you have any charts that you drew
insight from to say that? Of course, I have already been Googling the issue,
but we aren't necessarily looking at the same sources.

So where are you getting your information that Python is losing to the "it"
languages?

------
etfb
That's pretty cool. I like how it would seem to support literate programming
at a lower level than just extensive comments (which always seem to go stale)
or long variable names (which often hinder comprehension more than they help
it).

------
JulianWasTaken
A feature without a use case still unfortunately. There are some in the PEP,
but given how little code is Py3-only, no one has written anything notable
that I've seen that makes use of these.

~~~
michaelmior
This would be great to have some subset of Cython[1] become valid Python code
so it could be executed as normal Python code. The syntax is different, but
function annotations could provide the necessary info.

[1] [http://cython.org/](http://cython.org/)

~~~
andreasvc
It's already available as a beta feature in Cython.

~~~
guipsp
Link?

~~~
andreasvc
[http://article.gmane.org/gmane.comp.python.cython.user/11014](http://article.gmane.org/gmane.comp.python.cython.user/11014)

