News for hackers. Stuff that matters.
Re:PEP 3107 – Function Annotations in Python 3 by jerf on Monday May 12, 2014 @08:47AM (#7732373)
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.

Re:PEP 3107 – Function Annotations in Python 3 by pekk on Monday May 12, 2014 @01:16PM (#7734024)
By a language freeze, you mean that Python should never change again?
Re:PEP 3107 – Function Annotations in Python 3 by jerf on Monday May 12, 2014 @02:14PM (#7734436)
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.
Re:PEP 3107 – Function Annotations in Python 3 by ak217 on Monday May 12, 2014 @07:42AM (#7732141)
I've added a type checking decorator for function annotations to my assertions helper library, 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.
Re:PEP 3107 – Function Annotations in Python 3 by thomasahle on Monday May 12, 2014 @08:57AM (#7732412)
How does that work? Is it abusing dictionary syntax without braces?
Re:PEP 3107 – Function Annotations in Python 3 by ak217 on Monday May 12, 2014 @09:34AM (#7732559)
The PEP describes it nicely :)

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

Re:PEP 3107 – Function Annotations in Python 3 by unwind on Monday May 12, 2014 @07:15AM (#7732051)
OK, I'll bite: This is from [2010], so rather old.

What changed to make this relevant now?

Re:PEP 3107 – Function Annotations in Python 3 by saurik on Monday May 12, 2014 @07:54AM (#7732173)
No: this is from 2006; it was last modified in 2010, but the changes were negligible (a wording tweak), and earlier changes were even less important (updating hyperlinks).
Re:PEP 3107 – Function Annotations in Python 3 by philliproso on Monday May 12, 2014 @07:51AM (#7732165)
I think it's because some people are finally considering making pure python3 projects.
Re:PEP 3107 – Function Annotations in Python 3 by _pmf_ on Monday May 12, 2014 @08:34AM (#7732331)
> 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.

Re:PEP 3107 – Function Annotations in Python 3 by threatofrain on Monday May 12, 2014 @12:32PM (#7733724)
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?

Re:PEP 3107 – Function Annotations in Python 3 by coldtea on Monday May 12, 2014 @08:49AM (#7732379)
You can say the same for Algol or Cobol.

But then the stupidity of the statement would be immediately apparent.

Re:PEP 3107 – Function Annotations in Python 3 by etfb on Monday May 12, 2014 @08:37AM (#7732340)
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).
Re:PEP 3107 – Function Annotations in Python 3 by JulianWasTaken on Monday May 12, 2014 @07:14AM (#7732047)
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.
Re:PEP 3107 – Function Annotations in Python 3 by kunstmord on Monday May 12, 2014 @08:11AM (#7732252)
As mentioned, PyCharm supports this – I found it very useful when writing large amounts of code, saves time when trying to remember what type which variable should be (sometimes it's not evident from the input variable names).

And this looks a tad easier to find and understand than the standard docstring variable types description.

Re:PEP 3107 – Function Annotations in Python 3 by michaelmior on Monday May 12, 2014 @08:07AM (#7732233)
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/

Re:PEP 3107 – Function Annotations in Python 3 by d0mine on Monday May 12, 2014 @10:06PM (#7736306)
There is a pure python mode http://docs.cython.org/src/tutorial/pure.html that works even in Python 2.
Re:PEP 3107 – Function Annotations in Python 3 by andreasvc on Monday May 12, 2014 @09:49AM (#7732618)
It's already available as a beta feature in Cython.
Re:PEP 3107 – Function Annotations in Python 3 by guipsp on Monday May 12, 2014 @12:36PM (#7733742)
Link?
Re:PEP 3107 – Function Annotations in Python 3 by andreasvc on Monday May 12, 2014 @01:36PM (#7734170)
Re:PEP 3107 – Function Annotations in Python 3 by shoo on Monday May 12, 2014 @07:25AM (#7732086)
i agree with your sentiment but not how you have literally worded it - there are plenty of serious use cases listed in the PEP, eg typechecking by itself is rather useful in other languages, but it is perhaps hard to imagine how useful this feature will be if no existing libraries support it, and there is no common standard defining what any of the annotations could mean.

on the other hand, this could be quite useful for large (proprietary?) python codebases where common standards can be defined and rolled out and enforced.

Re:PEP 3107 – Function Annotations in Python 3 by philliproso on Monday May 12, 2014 @07:35AM (#7732119)
It is nicely integrated with type checking in the pycharm IDE. This feature is one of the reasons I would personally like to write pure py3 code.
Re:PEP 3107 – Function Annotations in Python 3 by lukasm on Monday May 12, 2014 @07:35AM (#7732117)
One use case: improved JITer performance.