Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-25 Thread Chris Angelico
On Sun, Apr 26, 2015 at 2:01 AM, Ronan Lamy wrote: >>> * PEP484 hints are too high-level. Replacing an 'int' object with a >>> single machine word would be useful, but an 'int' annotation gives no >>> guarantee that it's correct (because Python 3 ints can have arbitrary >>> size and because subcla

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-25 Thread Ronan Lamy
Le 25/04/15 04:07, Steven D'Aprano a écrit : On Sat, Apr 25, 2015 at 02:05:15AM +0100, Ronan Lamy wrote: * Hints have no run-time effect. The interpreter cannot assume that they are obeyed. I know what you mean, but just for the record, annotations are runtime inspectable, so people can (and

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-24 Thread Nick Coghlan
On 22 April 2015 at 03:03, Carol Willing wrote: > 2. Clearly, great thought has been put into this PEP. If anyone has a good > analysis of the potential impact on Python 3 adoption, please do pass along. > I would be interested in reading the information. I don't have hard data, but I do get to s

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-24 Thread Steven D'Aprano
On Sat, Apr 25, 2015 at 02:05:15AM +0100, Ronan Lamy wrote: > * Hints have no run-time effect. The interpreter cannot assume that they > are obeyed. I know what you mean, but just for the record, annotations are runtime inspectable, so people can (and probably have already started) to write ru

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-24 Thread Kevin Modzelewski
On Fri, Apr 24, 2015 at 6:05 PM, Ronan Lamy wrote: > Le 24/04/15 19:45, Paul Sokolovsky a écrit : > >> Hello, >> >> On Fri, 24 Apr 2015 18:27:29 +0100 >> Ronan Lamy wrote: >> >> PyPy's FAQ > has an explanation of why type hints are not for performance. > > http://pypy.readthedocs.or

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-24 Thread Ronan Lamy
Le 24/04/15 19:45, Paul Sokolovsky a écrit : Hello, On Fri, 24 Apr 2015 18:27:29 +0100 Ronan Lamy wrote: PyPy's FAQ has an explanation of why type hints are not for performance. http://pypy.readthedocs.org/en/latest/faq.html#would-type-annotations-help-pypy-s-performance You probably intend

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-24 Thread Paul Sokolovsky
Hello, On Fri, 24 Apr 2015 18:27:29 +0100 Ronan Lamy wrote: > Also ask why no one used type specifier, they are possible since > Python 3.0 ? > Because it is the wrong way for Python. > >>> > >>> That's an example of how perceptions differ. In my list, > >>> everyone(*) uses them

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-24 Thread Ronan Lamy
Le 23/04/15 14:55, Paul Sokolovsky a écrit : Hello, On Thu, 23 Apr 2015 09:15:44 -0400 Daniel Holth wrote: [] Also ask why no one used type specifier, they are possible since Python 3.0 ? Because it is the wrong way for Python. That's an example of how perceptions differ. In my list, every

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-23 Thread Steven D'Aprano
On Thu, Apr 23, 2015 at 03:25:30PM +0100, Harry Percival wrote: > lol @ the fact that the type hints are breaking github's syntax highlighter > :) That just tells us that Github's syntax highlighter has been broken for over five years. Function annotations go back to Python 3.0, more than five y

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-23 Thread Chris Barker
On Wed, Apr 22, 2015 at 5:45 PM, Guido van Rossum wrote: > Given that even if Difference existed, and even if we had a predefined > type alias for Difference[Iterable[str], str], you' still have to remember > to mark up all those functions with that annotation. It almost sounds > simpler to just

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-23 Thread Paul Sokolovsky
Hello, On Thu, 23 Apr 2015 15:25:30 +0100 Harry Percival wrote: > lol @ the fact that the type hints are breaking github's syntax > highlighter :) What one can expect from software written in Ruby? ;-) -- Best regards, Paul mailto:pmis...@gmail.com _

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-23 Thread Harry Percival
lol @ the fact that the type hints are breaking github's syntax highlighter :) On 23 April 2015 at 14:44, Paul Sokolovsky wrote: > Hello, > > On Thu, 23 Apr 2015 14:48:58 +0200 > Wolfgang Langner wrote: > > > Hello, > > > > On Thu, Apr 23, 2015 at 11:59 AM, Paul Sokolovsky > > wrote: > > > > >

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-23 Thread Daniel Holth
On Thu, Apr 23, 2015 at 9:55 AM, Paul Sokolovsky wrote: > Hello, > > On Thu, 23 Apr 2015 09:15:44 -0400 > Daniel Holth wrote: > > [] > >> >> Also ask why no one used type specifier, they are possible since >> >> Python 3.0 ? >> >> Because it is the wrong way for Python. >> > >> > That's an exampl

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-23 Thread Paul Sokolovsky
Hello, On Thu, 23 Apr 2015 09:15:44 -0400 Daniel Holth wrote: [] > >> Also ask why no one used type specifier, they are possible since > >> Python 3.0 ? > >> Because it is the wrong way for Python. > > > > That's an example of how perceptions differ. In my list, everyone(*) > > uses them - MyPy

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-23 Thread Paul Sokolovsky
Hello, On Thu, 23 Apr 2015 14:48:58 +0200 Wolfgang Langner wrote: > Hello, > > On Thu, Apr 23, 2015 at 11:59 AM, Paul Sokolovsky > wrote: > > > Hello, > > > > On Thu, 23 Apr 2015 10:43:52 +0200 > > Wolfgang Langner wrote: > > > > [] > > > > > Also ask why no one used type specifier, they are

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-23 Thread Daniel Holth
On Thu, Apr 23, 2015 at 5:59 AM, Paul Sokolovsky wrote: > Hello, > > On Thu, 23 Apr 2015 10:43:52 +0200 > Wolfgang Langner wrote: > > [] > >> Also ask why no one used type specifier, they are possible since >> Python 3.0 ? >> Because it is the wrong way for Python. > > That's an example of how pe

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-23 Thread Florian Bruhin
* Wolfgang Langner [2015-04-23 10:43:52 +0200]: > 2. Using it in the language as part of the function signature, my first > thought was oh good, then I changed my mind >to: oh it can be very ugly and unreadable, it is the wrong place. >Now I am against it, best is, if I have to specify typ

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-23 Thread Paul Sokolovsky
Hello, On Thu, 23 Apr 2015 10:43:52 +0200 Wolfgang Langner wrote: [] > Also ask why no one used type specifier, they are possible since > Python 3.0 ? > Because it is the wrong way for Python. That's an example of how perceptions differ. In my list, everyone(*) uses them - MyPy, MicroPython, e

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-23 Thread Wolfgang Langner
Hello, On Thu, Apr 23, 2015 at 11:59 AM, Paul Sokolovsky wrote: > Hello, > > On Thu, 23 Apr 2015 10:43:52 +0200 > Wolfgang Langner wrote: > > [] > > > Also ask why no one used type specifier, they are possible since > > Python 3.0 ? > > Because it is the wrong way for Python. > > That's an exam

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-23 Thread Wolfgang Langner
Hi, having a lot experience with Python beginners and people programming Java/Python I have also an opinion about this. ;-) First reaction was, oh good. Then I read every thread and comment about it, looked at a lot internal code give all some time and the result is: I found a lot of code writte

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-23 Thread Terry Reedy
On 4/22/2015 8:45 PM, Guido van Rossum wrote: On Wed, Apr 22, 2015 at 2:38 PM, Chris Barker mailto:chris.bar...@noaa.gov>> wrote: On Tue, Apr 21, 2015 at 11:32 PM, Terry Reedy mailto:tjre...@udel.edu>> wrote: I was just thinking today that for this, typing needs a subtract

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-22 Thread Guido van Rossum
On Wed, Apr 22, 2015 at 2:38 PM, Chris Barker wrote: > > > Oh wait, maybe it won't -- a string IS a sequence of strings. That's why >> this is an insidious bug in the first place. > > On Tue, Apr 21, 2015 at 11:32 PM, Terry Reedy wrote: > > >> I was just thinking today that for this, typing need

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-22 Thread Chris Barker
> Oh wait, maybe it won't -- a string IS a sequence of strings. That's why > this is an insidious bug in the first place. On Tue, Apr 21, 2015 at 11:32 PM, Terry Reedy wrote: > I was just thinking today that for this, typing needs a subtraction > (difference) operation in addition to an additio

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-22 Thread Cory Benfield
On 21 April 2015 at 17:59, Guido van Rossum wrote: > For me, PEP 484 is a stepping stone. Among the authors of PEP 484 there was > much discussion about duck typing, and mypy even has some limited support > for duck typing (I think you can still find it by searching the mypy code > for "protocol")

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-22 Thread Cory Benfield
On 21 April 2015 at 18:12, Steven D'Aprano wrote: > I expect that dealing with duck typing will be very high on the list > of priorities for the future. In the meantime, for this specific use-case, > you're probably not going to be able to statically check this type hint. > Your choices would be:

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-21 Thread Terry Reedy
On 4/21/2015 6:41 PM, Chris Barker wrote: Well, it'll catch passing in a string instead of a sequence of strings -- one of teh common and semi-insidious type errors I see a lot (at least with newbies). Oh wait, maybe it won't -- a string IS a sequence of strings. That's why this is an insidioou

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-21 Thread Terry Reedy
On 4/21/2015 6:50 PM, Chris Barker wrote: On Tue, Apr 21, 2015 at 11:58 AM, Paul Sokolovsky mailto:pmis...@gmail.com>> wrote: It does, and hope people won't be caught in "static typechecking" loop and consider other usages too. I an interested is using type hints for automatic or at le

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-21 Thread Robert Collins
On 22 April 2015 at 08:26, Guido van Rossum wrote: > In the end this should be up to you and the reviewers, but for such a > venerable module like unittest I'd be hesitant to be an early adopter. I'd > also expect that much of unittest is too dynamic in nature to benefit from > type hints. But ma

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-21 Thread James Edwards
Cory Benfield "python-dev@python.org" On Tue, Apr 21, 2015 at 8:47 AM, Cory Benfield wrote: > I'm talking from the position of being a library author, where supporting > versions of Python lower than 3.5 will be a reality for at least 5 more years. > I will not be able to inline my type hints,

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-21 Thread Chris Barker
Thank you Jack. Jack: "I hate code and I want as little of it as possible in our product" I love that quote -- and I ALWAYS use it when I teach newbies Python. It's kind of the point of Python -- you can get a lot done by writing very little code. I'm still confused about what all this type anno

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-21 Thread Chris Barker
On Tue, Apr 21, 2015 at 11:58 AM, Paul Sokolovsky wrote: > It does, and hope people won't be caught in "static typechecking" > loop and consider other usages too. > I"m confused -- from the bit I've been skimming the discussion, over on python-ideas, and now here, is that this is all about "stat

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-21 Thread Chris Barker
On Tue, Apr 21, 2015 at 2:33 AM, Cory Benfield wrote: > It seems like the only place the type annotations will get used is in > relatively trivial cases where the types are obvious anyway. I don't > deny that *some* bugs will be caught, but I suspect they'll > overwhelmingly be crass ones that wo

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-21 Thread Guido van Rossum
On Tue, Apr 21, 2015 at 1:18 PM, Robert Collins wrote: > On 22 April 2015 at 04:28, Guido van Rossum wrote: > > Until some point in a possible but distant future when we're all thinking > > back fondly about the argument we're currently having, it will be the > choice > > of the author of new (a

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-21 Thread Robert Collins
On 22 April 2015 at 04:28, Guido van Rossum wrote: > On Tue, Apr 21, 2015 at 12:49 AM, Antoine Pitrou > wrote: >> >> On Mon, 20 Apr 2015 20:43:38 -0400 >> "R. David Murray" wrote: >> > +1 to this from me too. I'm afraid that means I'm -1 on the PEP. >> > >> > I didn't write this in my earlier em

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-21 Thread Paul Moore
(Gmail messed up the attributions - apologies if I didn't fix them up correctly). 21 April 2015 at 19:55, Łukasz Langa wrote: >> >> On Apr 21, 2015, at 11:23 AM, Guido van Rossum wrote: >> >>> 2. Clearly, great thought has been put into this PEP. If anyone has a good >>> analysis of the potenti

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-21 Thread R. David Murray
On Tue, 21 Apr 2015 21:31:49 +0300, Paul Sokolovsky wrote: > On Tue, 21 Apr 2015 09:50:59 -0700 Ethan Furman wrote: > > > On 04/21, Paul Sokolovsky wrote: > > > > > > And for example yesterday's big theme was people blackmailing that > > > they stop contributing to stdlib if annotations are in

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-21 Thread Paul Moore
On 21 April 2015 at 17:55, Gregory P. Smith wrote: > I view most of this thread as FUD. The fear is understandable, I'm trying to > tell people to stop panicing. I think (hope!) everyone is clear that what's being expressed in this thread is honest (emotional) reactions. There's a negative connot

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-21 Thread Paul Sokolovsky
Hello, On Tue, 21 Apr 2015 12:17:01 -0400 "R. David Murray" wrote: > On Tue, 21 Apr 2015 18:27:50 +0300, Paul Sokolovsky > wrote: > > > I was replying to Steven's message. Did you read it? > > > > Yes. And I try to follow general course of discussion, as its hard > > to follow individual sub-t

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-21 Thread Łukasz Langa
> On Apr 21, 2015, at 11:23 AM, Guido van Rossum wrote: > > 2. Clearly, great thought has been put into this PEP. If anyone has a good > analysis of the potential impact on Python 3 adoption, please do pass along. > I would be interested in reading the information. > > I wish I had a crystal

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-21 Thread Alexander Belopolsky
On Tue, Apr 21, 2015 at 2:23 PM, Guido van Rossum wrote: > At least nobody will be writing type hints in Cyrillic. :-) Why not? It works just fine: >>> Список = list >>> def sum(x: Список): ... pass ... >>> (See https://en.wikipedia.org/wiki/Rapira for some prior art.) _

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-21 Thread Paul Sokolovsky
Hello, On Tue, 21 Apr 2015 09:50:59 -0700 Ethan Furman wrote: > On 04/21, Paul Sokolovsky wrote: > > > > And for example yesterday's big theme was people blackmailing that > > they stop contributing to stdlib if annotations are in [...] > > A volunteer's honest reaction is not blackmail, and c

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-21 Thread Guido van Rossum
On Tue, Apr 21, 2015 at 10:03 AM, Carol Willing < willi...@willingconsulting.com> wrote: > > Two areas of clarification would be helpful for me: > > 1. Optional: What does this really mean in practice? Am I opting in to > static type checking and type hints? Or must I opt out of type hints? > Havi

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-21 Thread Carol Willing
On 4/21/15 9:17 AM, R. David Murray wrote: Please be respectful rather than inflammatory. Thank you David. If you read what I wrote, I did not say that I was going to stop contributing, I specifically talked about that gut reaction being both emotional and illogical. That doesn't make the reac

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-21 Thread R. David Murray
On Tue, 21 Apr 2015 10:10:06 -0700, Guido van Rossum wrote: > On Tue, Apr 21, 2015 at 9:17 AM, R. David Murray > wrote: > > > Please be respectful rather than inflammatory. If you read what I > > wrote, I did not say that I was going to stop contributing, I > > specifically talked about that gu

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-21 Thread R. David Murray
On Tue, 21 Apr 2015 16:55:49 -, "Gregory P. Smith" wrote: > We will not be putting type annotations anywhere in the stdlib or expecting > anyone else to maintain them there. That would never happen until tools > that are convincing enough in their utility for developers to _want_ to use > are

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-21 Thread Daniel Holth
On Tue, Apr 21, 2015 at 1:10 PM, Guido van Rossum wrote: > On Tue, Apr 21, 2015 at 9:17 AM, R. David Murray > wrote: >> >> Please be respectful rather than inflammatory. If you read what I >> wrote, I did not say that I was going to stop contributing, I >> specifically talked about that gut reac

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-21 Thread Guido van Rossum
On Tue, Apr 21, 2015 at 9:47 AM, Antoine Pitrou wrote: > On Tue, 21 Apr 2015 09:28:45 -0700 > Guido van Rossum wrote: > > On Tue, Apr 21, 2015 at 12:49 AM, Antoine Pitrou > > wrote: > > > > > On Mon, 20 Apr 2015 20:43:38 -0400 > > > "R. David Murray" wrote: > > > > +1 to this from me too. I'm

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-21 Thread Antoine Pitrou
On Tue, 21 Apr 2015 18:27:50 +0300 Paul Sokolovsky wrote: > Let me try: MicroPython already uses type annotations for statically > typed functions. E.g. > > def add(x:int, y:int): > return x + y > > will translate the function to just 2 machine instructions. That's quite nice. > Oh really,

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-21 Thread Steven D'Aprano
On Tue, Apr 21, 2015 at 03:51:05PM +0100, Cory Benfield wrote: > On 21 April 2015 at 15:31, Chris Angelico wrote: > > Granted, there are some > > vague areas - how many functions take a "file-like object", and are > > they all the same? - but between MyPy types and the abstract base > > types that

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-21 Thread Guido van Rossum
On Tue, Apr 21, 2015 at 9:17 AM, R. David Murray wrote: > Please be respectful rather than inflammatory. If you read what I > wrote, I did not say that I was going to stop contributing, I > specifically talked about that gut reaction being both emotional and > illogical. That doesn't make the r

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-21 Thread Nikolaus Rath
On Apr 21 2015, Paul Sokolovsky wrote: > Hello, > > On Tue, 21 Apr 2015 08:05:59 -0700 > Nikolaus Rath wrote: > >> On Apr 20 2015, Chris Angelico wrote: >> > Maybe it'd be of value to have a quick "code stripper" that takes >> > away all the annotations, plus any other junk/framing that you're >

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-21 Thread Guido van Rossum
On Tue, Apr 21, 2015 at 7:51 AM, Cory Benfield wrote: > The correct specification is "read method with this type signature" > and "seek method with this type signature". I would even be prepared > to waive the type signatures on read and seek, given that enforcing > the type hinting on others is

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-21 Thread Gregory P. Smith
On Tue, Apr 21, 2015 at 12:50 AM Antoine Pitrou wrote: > On Mon, 20 Apr 2015 20:43:38 -0400 > "R. David Murray" wrote: > > +1 to this from me too. I'm afraid that means I'm -1 on the PEP. > > > > I didn't write this in my earlier email because I wasn't sure about it, > > but my gut reaction afte

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-21 Thread Ethan Furman
On 04/21, Paul Sokolovsky wrote: > > And for example yesterday's big theme was people blackmailing that they > stop contributing to stdlib if annotations are in [...] A volunteer's honest reaction is not blackmail, and categorizing it as such is not helpful to the discussion. -- ~Ethan~

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-21 Thread Antoine Pitrou
On Tue, 21 Apr 2015 09:28:45 -0700 Guido van Rossum wrote: > On Tue, Apr 21, 2015 at 12:49 AM, Antoine Pitrou > wrote: > > > On Mon, 20 Apr 2015 20:43:38 -0400 > > "R. David Murray" wrote: > > > +1 to this from me too. I'm afraid that means I'm -1 on the PEP. > > > > > > I didn't write this in

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-21 Thread Guido van Rossum
On Tue, Apr 21, 2015 at 12:49 AM, Antoine Pitrou wrote: > On Mon, 20 Apr 2015 20:43:38 -0400 > "R. David Murray" wrote: > > +1 to this from me too. I'm afraid that means I'm -1 on the PEP. > > > > I didn't write this in my earlier email because I wasn't sure about it, > > but my gut reaction aft

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-21 Thread R. David Murray
On Tue, 21 Apr 2015 18:27:50 +0300, Paul Sokolovsky wrote: > > I was replying to Steven's message. Did you read it? > > Yes. And I try to follow general course of discussion, as its hard to > follow individual sub-threads. And for example yesterday's big theme > was people blackmailing that they

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-21 Thread R. David Murray
On Wed, 22 Apr 2015 01:09:52 +1000, Chris Angelico wrote: > def incremental_parser(input: FileLike) -> List[Token]: > tokens = [] > data = "" > while True: > if not data: > data = input.read(64) > token = Token(data[0]); data = data[1:] > while token

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-21 Thread Jim Baker
On Tue, Apr 21, 2015 at 9:09 AM, Chris Angelico wrote: > ... > > Pretty accurate, yeah. Here's how I see it: > > def incremental_parser(input: FileLike) -> List[Token]: > tokens = [] > data = "" > while True: > if not data: > data = input.read(64) > token =

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-21 Thread Cory Benfield
On 21 April 2015 at 16:09, Chris Angelico wrote: > Pretty accurate, yeah. Here's how I see it: > > def incremental_parser(input: FileLike) -> List[Token]: > tokens = [] > data = "" > while True: > if not data: > data = input.read(64) > token = Token(data[0])

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-21 Thread Paul Sokolovsky
Hello, On Tue, 21 Apr 2015 08:05:59 -0700 Nikolaus Rath wrote: > On Apr 20 2015, Chris Angelico wrote: > > Maybe it'd be of value to have a quick "code stripper" that takes > > away all the annotations, plus any other junk/framing that you're > > not interested in, and gives you something you c

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-21 Thread Paul Sokolovsky
Hello, On Tue, 21 Apr 2015 16:11:51 +0200 Antoine Pitrou wrote: [] > >> You can't at the same time point out that type checking has no > >> power or control over runtime behaviour, and then claim that type > >> checking makes runtime behaviour (for example, ability to accept or > >> reject certa

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-21 Thread Chris Angelico
On Wed, Apr 22, 2015 at 12:51 AM, Cory Benfield wrote: > On 21 April 2015 at 15:31, Chris Angelico wrote: >> Granted, there are some >> vague areas - how many functions take a "file-like object", and are >> they all the same? - but between MyPy types and the abstract base >> types that already ex

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-21 Thread Nikolaus Rath
On Apr 20 2015, Chris Angelico wrote: > Maybe it'd be of value to have a quick "code stripper" that takes away > all the annotations, plus any other junk/framing that you're not > interested in, and gives you something you can browse in a text > editor? If you need to preprocess your source code

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-21 Thread Cory Benfield
On 21 April 2015 at 15:31, Chris Angelico wrote: > Granted, there are some > vague areas - how many functions take a "file-like object", and are > they all the same? - but between MyPy types and the abstract base > types that already exist, there are plenty of ways to formalize duck > typing. Are

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-21 Thread Alexander Walters
So. This is how you try and get me to care about Python 3. Can't speak for others, but this does the opposite for me. This makes me ecstatic that Python 2 has a nearly-frozen api. ___ Python-Dev mailing list Python-Dev@python.org https://mail.python

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-21 Thread Paul Sokolovsky
Hello, On Tue, 21 Apr 2015 15:08:27 +0200 Antoine Pitrou wrote: [] > Because the user might not run the type checker, obviously. To quote > you: """When we say that type checking is optional, we mean it.""" > > You can't at the same time point out that type checking has no > power or control o

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-21 Thread Chris Angelico
On Tue, Apr 21, 2015 at 7:56 PM, Arnaud Delobelle wrote: > If people constantly get told by their editor / IDE that they are calling > function with the wrong argument types, what are they going to do? They may > start adopting the same approach as in Java / C++ etc... where interfaces > must be

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-21 Thread Antoine Pitrou
Le 21/04/2015 15:50, Paul Sokolovsky a écrit : > Hello, > > On Tue, 21 Apr 2015 15:08:27 +0200 > Antoine Pitrou wrote: > > [] > >> Because the user might not run the type checker, obviously. To quote >> you: """When we say that type checking is optional, we mean it.""" >> >> You can't at the sa

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-21 Thread Steven D'Aprano
On Tue, Apr 21, 2015 at 03:08:27PM +0200, Antoine Pitrou wrote: > On Tue, 21 Apr 2015 22:47:23 +1000 > Steven D'Aprano wrote: > > > > Ironically, type hinting will *reduce* the need for intrusive, > > anti-duck-testing explicit calls to isinstance() at runtime: > > It won't, since as you pointe

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-21 Thread Barry Warsaw
On Apr 21, 2015, at 01:34 PM, Steven D'Aprano wrote: >Putting the type information in a stub file is an exponentially more distant >fourth best, or to put it another way, *the worst* solution for where to put >type hints. Not only do you Repeat Yourself with the name of the parameter, >but also th

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-21 Thread Paul Sokolovsky
Hello, On Tue, 21 Apr 2015 11:56:15 +0100 Rob Cliffe wrote: > On 21/04/2015 10:33, Cory Benfield wrote: > > On 21 April 2015 at 10:10, Chris Angelico wrote: > >> At this point, you may want to just stop caring about the exact > >> type. Part of the point of gradual typing is that you can > >> s

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-21 Thread Arnaud Delobelle
On Tue, 21 Apr 2015 at 09:59 Cory Benfield wrote: [...] > Further, Python's type system is not sufficiently flexible to allow > library authors to adequately specify the types their code actually > works on. I need to be able to talk about interfaces, because > interfaces are the contract around

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-21 Thread Harry Percival
Hey, I just wanted to say to everyone, thanks for being so patient and willing to engage with this discussion, despite my not having done my research and read the (substantial) prior discussion on the topic. Here it is (or at least, some of it!) for any other newcomers: https://mail.python.org/p

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-21 Thread Chris Withers
On 20/04/2015 19:30, Harry Percival wrote: Hi all, tldr; type hints in python source are scary. Would reserving them for stub files be better? I was trying to find Jack's original post as I think his summary is excellent and aligns well with where I think I'm coming from on this: https://mai

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-21 Thread Chris Withers
On 20/04/2015 20:09, Paul Moore wrote: On 20 April 2015 at 19:41, Barry Warsaw wrote: tldr; type hints in python source are scary. Would reserving them for stub files be better? I think so. I think PEP 8 should require stub files for stdlib modules and strongly encourage them for 3rd party co

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-21 Thread Antoine Pitrou
On Tue, 21 Apr 2015 23:16:19 +1000 Steven D'Aprano wrote: > > I could keep going, but I hope I've made my point. I don't think so. Just because other languages are looking at it doesn't mean it will end up successful. It means it's an interesting idea, that's all. A litmus test for this PEP wou

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-21 Thread Paul Moore
On 21 April 2015 at 13:47, Steven D'Aprano wrote: > On Tue, Apr 21, 2015 at 11:56:15AM +0100, Rob Cliffe wrote: > >> (Adding a type hint that restricted the argument to say a >> sequence of numbers turns out to be a mistake. > > Let's find out how big a mistake it is with an test run. > >

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-21 Thread Steven D'Aprano
On Tue, Apr 21, 2015 at 01:25:34PM +0100, Chris Withers wrote: > Anyway, I've not posted much to python-dev in quite a while, but this is > a topic that I would be kicking myself in 5-10 years time when I've had > to move to Javascript or because everyone > else has drifted away from Python as

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-21 Thread Antoine Pitrou
On Tue, 21 Apr 2015 22:47:23 +1000 Steven D'Aprano wrote: > > Ironically, type hinting will *reduce* the need for intrusive, > anti-duck-testing explicit calls to isinstance() at runtime: It won't, since as you pointed out yourself, type checks are purely optional and entirely separate from com

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-21 Thread Cory Benfield
On 21 April 2015 at 12:23, Gustavo Carneiro wrote: > Documentation is not checked. It often loses sync with the actual code. > Docs say one thing, code does another. Agreed. I don't think anyone would disagree here. I'm talking from the position of being a library author, where supporting versio

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-21 Thread Steven D'Aprano
On Tue, Apr 21, 2015 at 11:56:15AM +0100, Rob Cliffe wrote: > (Adding a type hint that restricted the argument to say a > sequence of numbers turns out to be a mistake. Let's find out how big a mistake it is with an test run. py> def sorter(alist: List[int]) -> List[int]: ... return

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-21 Thread Chris Withers
On 21/04/2015 12:23, Gustavo Carneiro wrote: Well, (i) can be done with good documentation (docstrings etc.). Documentation is not checked. It often loses sync with the actual code. Docs say one thing, code does another. That certainly something that could be fixed by formalising th

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-21 Thread Chris Withers
On 20/04/2015 19:30, Harry Percival wrote: Hi all, tldr; type hints in python source are scary. Would reserving them for stub files be better? I think Jack's summary of this is excellent and aligns well with where I think I'm coming from on this: https://mail.python.org/pipermail/python-dev

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-21 Thread Chris Withers
On 20/04/2015 20:09, Paul Moore wrote: On 20 April 2015 at 19:41, Barry Warsaw wrote: tldr; type hints in python source are scary. Would reserving them for stub files be better? I think so. I think PEP 8 should require stub files for stdlib modules and strongly encourage them for 3rd party co

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-21 Thread Gustavo Carneiro
On 21 April 2015 at 11:56, Rob Cliffe wrote: > On 21/04/2015 10:33, Cory Benfield wrote: > > On 21 April 2015 at 10:10, Chris Angelico > wrote: > > At this point, you may want to just stop caring about the exact type. > Part of the point of gradual typing is that you can short-cut a lot of >

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-21 Thread Rob Cliffe
On 21/04/2015 10:33, Cory Benfield wrote: On 21 April 2015 at 10:10, Chris Angelico wrote: At this point, you may want to just stop caring about the exact type. Part of the point of gradual typing is that you can short-cut a lot of this. And quite frankly, this isn't really helping anything. Ju

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-21 Thread Steven D'Aprano
On Mon, Apr 20, 2015 at 08:37:28PM -0700, Guido van Rossum wrote: > On Mon, Apr 20, 2015 at 4:41 PM, Jack Diederich wrote: > > > Twelve years ago a wise man said to me "I suggest that you also propose a > > new name for the resulting language" > > > > The barrage of FUD makes me feel like the wo

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-21 Thread Cory Benfield
On 21 April 2015 at 10:10, Chris Angelico wrote: > At this point, you may want to just stop caring about the exact type. > Part of the point of gradual typing is that you can short-cut a lot of > this. And quite frankly, this isn't really helping anything. Just skip > it and say that it's Union[Ma

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-21 Thread Chris Angelico
On Tue, Apr 21, 2015 at 6:58 PM, Cory Benfield wrote: > On 21 April 2015 at 01:45, Chris Angelico wrote: >> When you're writing a library, it can be a great help to provide type >> annotations, because every application that uses your library can >> benefit. > > It can be a great help to whom? No

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-21 Thread Cory Benfield
On 21 April 2015 at 01:45, Chris Angelico wrote: > When you're writing a library, it can be a great help to provide type > annotations, because every application that uses your library can > benefit. It can be a great help to whom? Not to me (the library author), because I can't use them in my li

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-21 Thread Antoine Pitrou
On Mon, 20 Apr 2015 20:43:38 -0400 "R. David Murray" wrote: > +1 to this from me too. I'm afraid that means I'm -1 on the PEP. > > I didn't write this in my earlier email because I wasn't sure about it, > but my gut reaction after reading Harry's email was "if type annotations > are used in the s

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-20 Thread Terry Reedy
On 4/20/2015 9:07 PM, Chris Angelico wrote: On Tue, Apr 21, 2015 at 10:52 AM, Ben Finney wrote: Jack is not complaining only about *writing* code. He's complaining about the effect this will have on code that we all are expected to *read*. For reading, good function and parameter names and

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-20 Thread Guido van Rossum
On Mon, Apr 20, 2015 at 4:41 PM, Jack Diederich wrote: > Twelve years ago a wise man said to me "I suggest that you also propose a > new name for the resulting language" > The barrage of FUD makes me feel like the woman who asked her doctor for a second opinion and was told "you're ugly too."

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-20 Thread Steven D'Aprano
On Mon, Apr 20, 2015 at 02:41:06PM -0400, Barry Warsaw wrote: > On Apr 20, 2015, at 07:30 PM, Harry Percival wrote: > > >tldr; type hints in python source are scary. Would reserving them for stub > >files be better? > > I think so. I think PEP 8 should require stub files for stdlib modules and >

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-20 Thread Steven D'Aprano
On Mon, Apr 20, 2015 at 07:30:39PM +0100, Harry Percival wrote: > Hi all, > > tldr; type hints in python source are scary. Would reserving them for stub > files be better? No no no, a thousand times no it would not! Please excuse my extreme reaction, but over on the python-list mailing list (co

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-20 Thread Steven D'Aprano
On Mon, Apr 20, 2015 at 11:34:51PM +0100, Harry Percival wrote: > exactly. yay stub files! we all agree! everyone loves them! Not even close. -- Steve ___ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-20 Thread Nick Coghlan
On 20 Apr 2015 14:44, "Barry Warsaw" wrote: > > On Apr 20, 2015, at 07:30 PM, Harry Percival wrote: > > >tldr; type hints in python source are scary. Would reserving them for stub > >files be better? > > I think so. I think PEP 8 should require stub files for stdlib modules and > strongly encoura

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-20 Thread Chris Angelico
On Tue, Apr 21, 2015 at 10:52 AM, Ben Finney wrote: > Chris Angelico writes: > >> On Tue, Apr 21, 2015 at 9:41 AM, Jack Diederich wrote: >> > * It is not optional. Please stop saying that. The people promoting >> > it would prefer that everyone use it. If it is approved it will be >> > optional

Re: [Python-Dev] Type hints -- a mediocre programmer's reaction

2015-04-20 Thread Ben Finney
Chris Angelico writes: > On Tue, Apr 21, 2015 at 9:41 AM, Jack Diederich wrote: > > * It is not optional. Please stop saying that. The people promoting > > it would prefer that everyone use it. If it is approved it will be > > optional in the way that PEP8 is optional. If I'm reading your > > an

  1   2   >