Re: [Python-Dev] PEP 529: Change Windows filesystem encoding to UTF-8

2016-09-04 Thread Steve Dower
I posted an update to PEP 529 at https://github.com/python/peps/blob/master/pep-0529.txt and a diff below. The update includes more detail on the affected code within CPython - including a number of references to broken code that would be resolved with the change - and more details about the ne

Re: [Python-Dev] PEP 528: Change Windows console encoding to UTF-8

2016-09-04 Thread Steve Dower
I posted a minor update to PEP 528 at https://github.com/python/peps/blob/master/pep-0528.txt and a diff below. While there are likely to be technical and compatibility issues to resolve after the changes are applied, I don't believe they impact the decision to accept the change at the PEP-lev

Re: [Python-Dev] PEP 467: last round (?)

2016-09-04 Thread Nick Coghlan
On 5 September 2016 at 06:42, Koos Zevenhoven wrote: > On Sun, Sep 4, 2016 at 6:38 PM, Nick Coghlan wrote: >> >> There are two self-consistent sets of names: >> > > Let me add a few. I wonder if this is really used so much that > bytes.chr is too long to type (and you can do bchr = bytes.chr if y

Re: [Python-Dev] Please reject or postpone PEP 526

2016-09-04 Thread Nick Coghlan
On 5 September 2016 at 04:40, Koos Zevenhoven wrote: > On Sun, Sep 4, 2016 at 9:13 PM, Ivan Levkivskyi wrote: >> On 4 September 2016 at 19:59, Nick Coghlan wrote: > [...] >>> >>> Similarly, it would be reasonable to say that these three snippets >>> should all be equivalent from a typechecking p

Re: [Python-Dev] PEP 467: last round (?)

2016-09-04 Thread Random832
On Sun, Sep 4, 2016, at 16:42, Koos Zevenhoven wrote: > On Sun, Sep 4, 2016 at 6:38 PM, Nick Coghlan wrote: > > > > There are two self-consistent sets of names: > > > > Let me add a few. I wonder if this is really used so much that > bytes.chr is too long to type (and you can do bchr = bytes.chr

Re: [Python-Dev] Please reject or postpone PEP 526

2016-09-04 Thread Greg Ewing
On Sun, Sep 04, 2016 at 12:31:26PM +0100, Mark Shannon wrote: As defined in PEP 526, I think that type annotations become a hindrance to type inference. In Haskell-like languages, type annotations have no ability to influence whether types can be inferred. The compiler infers a type for everyt

Re: [Python-Dev] PEP 467: last round (?)

2016-09-04 Thread Koos Zevenhoven
On Sun, Sep 4, 2016 at 6:38 PM, Nick Coghlan wrote: > > There are two self-consistent sets of names: > Let me add a few. I wonder if this is really used so much that bytes.chr is too long to type (and you can do bchr = bytes.chr if you want to): bytes.chr (or bchr in builtins) bytes.chr_at, byte

Re: [Python-Dev] Please reject or postpone PEP 526

2016-09-04 Thread Guido van Rossum
Everybody please stop panicking. PEP 526 does not make a stand on the behavior of type checkers (other than deferring to PEP 484). If you want to start a discussion about constraining type checkers please do it over at python-ideas. There is no rush as type checkers are not affected by the feature

Re: [Python-Dev] Please reject or postpone PEP 526

2016-09-04 Thread Koos Zevenhoven
On Sun, Sep 4, 2016 at 9:13 PM, Ivan Levkivskyi wrote: > On 4 September 2016 at 19:59, Nick Coghlan wrote: [...] >> >> Similarly, it would be reasonable to say that these three snippets >> should all be equivalent from a typechecking perspective: >> >> x = None # type: Optional[T] >> >> x

Re: [Python-Dev] Please reject or postpone PEP 526

2016-09-04 Thread Nick Coghlan
On 5 September 2016 at 04:13, Ivan Levkivskyi wrote: > On 4 September 2016 at 19:59, Nick Coghlan wrote: >> I suspect you'll have an easier time of it on that front if you >> include some examples of dynamically typed code that a well-behaved >> type-checker *must* report as correct Python code,

Re: [Python-Dev] Please reject or postpone PEP 526

2016-09-04 Thread Ivan Levkivskyi
On 4 September 2016 at 19:59, Nick Coghlan wrote: Nick, Thank you for good suggestions. > I mostly agree, but the PEP still needs to address the fact that it's > only a subset of the benefits that actually require new syntax, since > it's that subset which provides the rationale for rejecting

Re: [Python-Dev] Please reject or postpone PEP 526

2016-09-04 Thread Nick Coghlan
On 5 September 2016 at 03:23, Ivan Levkivskyi wrote: > On 4 September 2016 at 18:43, Nick Coghlan wrote: >> >> On 4 September 2016 at 21:32, Ivan Levkivskyi >> wrote: >> > The first form still could be interpreted by type checkers >> > as annotation for value (a cast to more precise type): >> >

Re: [Python-Dev] Please reject or postpone PEP 526

2016-09-04 Thread Ivan Levkivskyi
On 4 September 2016 at 19:29, Nick Coghlan wrote: > So in this case, attempting to entirely defer specification of the > semantics creates a significant risk of type checkers written on the > assumption of C++ or Java style type declarations actively inhibiting > the dynamism of Python code, sugg

Re: [Python-Dev] Please reject or postpone PEP 526

2016-09-04 Thread Nick Coghlan
On 4 September 2016 at 21:51, Steven D'Aprano wrote: > On Sun, Sep 04, 2016 at 12:31:26PM +0100, Mark Shannon wrote: > >> In other words PEP 484 specifically states that annotations are to help >> with type inference. As defined in PEP 526, I think that type >> annotations become a hindrance to ty

Re: [Python-Dev] Please reject or postpone PEP 526

2016-09-04 Thread Ivan Levkivskyi
On 4 September 2016 at 18:43, Nick Coghlan wrote: > On 4 September 2016 at 21:32, Ivan Levkivskyi > wrote: > > The first form still could be interpreted by type checkers > > as annotation for value (a cast to more precise type): > > > > variable = cast(annotation, value) # visually also looks si

Re: [Python-Dev] Please reject or postpone PEP 526

2016-09-04 Thread Koos Zevenhoven
On Sun, Sep 4, 2016 at 7:43 PM, Nick Coghlan wrote: > On 4 September 2016 at 21:32, Ivan Levkivskyi wrote: >> The first form still could be interpreted by type checkers >> as annotation for value (a cast to more precise type): >> >> variable = cast(annotation, value) # visually also looks similar

Re: [Python-Dev] Please reject or postpone PEP 526

2016-09-04 Thread Nick Coghlan
On 4 September 2016 at 21:32, Ivan Levkivskyi wrote: > The first form still could be interpreted by type checkers > as annotation for value (a cast to more precise type): > > variable = cast(annotation, value) # visually also looks similar I think a function based spelling needs to be discussed f

Re: [Python-Dev] Patch reviews

2016-09-04 Thread Nick Coghlan
On 4 September 2016 at 20:57, Christian Heimes wrote: > On 2016-09-01 23:15, Victor Stinner wrote: >> 2016-08-31 22:31 GMT+02:00 Christian Heimes : >>> https://bugs.python.org/issue27744 >>> Add AF_ALG (Linux Kernel crypto) to socket module >> >> This patch adds a new socket.sendmsg_afalg() method

Re: [Python-Dev] PEP 467: last round (?)

2016-09-04 Thread Nick Coghlan
On 4 September 2016 at 20:43, Koos Zevenhoven wrote: > On Sun, Sep 4, 2016 at 12:51 PM, Nick Coghlan wrote: >> That said, the PEP does propose "getbyte()" and "iterbytes()" for >> bytes-oriented indexing and iteration, so there's a reasonable >> consistency argument in favour of also proposing "b

Re: [Python-Dev] Please reject or postpone PEP 526

2016-09-04 Thread Koos Zevenhoven
On Sun, Sep 4, 2016 at 3:43 PM, Steven D'Aprano wrote: [...] > [steve@ando ~]$ cat test.py > from typing import Optional > > def foo(x:Optional[int])->int: > if x is None: > return -1 > return x + 1 > > def bar(x:Optional[int])->int: > y = x # the type of y must be inferred >

Re: [Python-Dev] Please reject or postpone PEP 526

2016-09-04 Thread Ivan Levkivskyi
On 4 September 2016 at 15:07, Steven D'Aprano wrote: > > PEP 526 > > variable: annotation = value > > > > Which reads very much as if the annotation refers to the variable. > > Since the PEP makes it clear that the two forms are to be treated the > same, I think that whatever difference you think

Re: [Python-Dev] Please reject or postpone PEP 526

2016-09-04 Thread Steven D'Aprano
Referring to the alternative syntax forms: # Proposed x: int = func(value) # Already accepted x = func(value) #type: int On Sun, Sep 04, 2016 at 11:52:24AM +0100, Mark Shannon wrote: > The key difference is in placement. > PEP 484 style > variable = value # annotation > > Whi

Re: [Python-Dev] Please reject or postpone PEP 526

2016-09-04 Thread Steven D'Aprano
On Sun, Sep 04, 2016 at 12:30:18PM +0100, Mark Shannon wrote: > It would be a real shame if PEP 526 mandates against checkers doing as > good as job as possible. Forcing all uses of a variable to have the same > type is a major and, IMO crippling, limitation. This is approaching FUD. Guido has

Re: [Python-Dev] Please reject or postpone PEP 526

2016-09-04 Thread Koos Zevenhoven
On Sun, Sep 4, 2016 at 1:52 PM, Mark Shannon wrote: [...] > > The key difference is in placement. > PEP 484 style > variable = value # annotation > > Which reads to me as if the annotation refers to the value. > PEP 526 > variable: annotation = value > > Which reads very much as if the annotation

Re: [Python-Dev] Please reject or postpone PEP 526

2016-09-04 Thread Ivan Levkivskyi
On 4 September 2016 at 13:30, Mark Shannon wrote: > It would be a real shame if PEP 526 mandates against checkers doing as > good as job as possible. Forcing all uses of a variable to have the same > type is a major and, IMO crippling, limitation. > > E.g. > def foo(x:Optional[int])->int: > i

Re: [Python-Dev] Please reject or postpone PEP 526

2016-09-04 Thread Steven D'Aprano
On Sun, Sep 04, 2016 at 12:31:26PM +0100, Mark Shannon wrote: > In other words PEP 484 specifically states that annotations are to help > with type inference. As defined in PEP 526, I think that type > annotations become a hindrance to type inference. I'm pretty sure that they don't. Have you

Re: [Python-Dev] Please reject or postpone PEP 526

2016-09-04 Thread Mark Shannon
On 04/09/16 11:57, Chris Angelico wrote: On Sun, Sep 4, 2016 at 8:52 PM, Mark Shannon wrote: The key difference is in placement. PEP 484 style variable = value # annotation Which reads to me as if the annotation refers to the value. PEP 526 variable: annotation = value Which reads very much

Re: [Python-Dev] Please reject or postpone PEP 526

2016-09-04 Thread Ivan Levkivskyi
On 4 September 2016 at 12:52, Mark Shannon wrote: > The key difference is in placement. > PEP 484 style > variable = value # annotation > > Which reads to me as if the annotation refers to the value. > PEP 526 > variable: annotation = value > > Which reads very much as if the annotation refers to

Re: [Python-Dev] Please reject or postpone PEP 526

2016-09-04 Thread Mark Shannon
On 02/09/16 20:33, Guido van Rossum wrote: On Fri, Sep 2, 2016 at 10:47 AM, Steve Dower wrote: "I'm not seeing what distinction you think you are making here. What distinction do you see between: x: int = func(value) and x = func(value) # type: int" Not sure whether I agree with

Re: [Python-Dev] Patch reviews

2016-09-04 Thread Christian Heimes
On 2016-09-01 23:15, Victor Stinner wrote: > 2016-08-31 22:31 GMT+02:00 Christian Heimes : >> https://bugs.python.org/issue27744 >> Add AF_ALG (Linux Kernel crypto) to socket module > > This patch adds a new socket.sendmsg_afalg() method on Linux. > > "afalg" comes from AF_ALG which means "Addres

Re: [Python-Dev] Please reject or postpone PEP 526

2016-09-04 Thread Chris Angelico
On Sun, Sep 4, 2016 at 8:52 PM, Mark Shannon wrote: > The key difference is in placement. > PEP 484 style > variable = value # annotation > > Which reads to me as if the annotation refers to the value. > PEP 526 > variable: annotation = value > > Which reads very much as if the annotation refers t

Re: [Python-Dev] Please reject or postpone PEP 526

2016-09-04 Thread Mark Shannon
On 02/09/16 19:19, Steven D'Aprano wrote: On Fri, Sep 02, 2016 at 10:47:41AM -0700, Steve Dower wrote: "I'm not seeing what distinction you think you are making here. What distinction do you see between: x: int = func(value) and x = func(value) #type: int" Not sure whether I agree w

Re: [Python-Dev] PEP 467: last round (?)

2016-09-04 Thread Koos Zevenhoven
On Sun, Sep 4, 2016 at 12:51 PM, Nick Coghlan wrote: > On 4 September 2016 at 08:11, Random832 wrote: >> On Sat, Sep 3, 2016, at 18:06, Koos Zevenhoven wrote: >>> I guess one reason I don't like bchr (nor chrb, really) is that they >>> look just like a random sequence of letters in builtins, but

Re: [Python-Dev] Please reject or postpone PEP 526

2016-09-04 Thread Mark Shannon
On 02/09/16 19:04, Steven D'Aprano wrote: On Fri, Sep 02, 2016 at 08:10:24PM +0300, Koos Zevenhoven wrote: A good checker should be able to infer that x is a union type at the point that it's passed to spam, even without the type annotation. For example: def eggs(cond:bool): if cond:

Re: [Python-Dev] PEP 467: last round (?)

2016-09-04 Thread Nick Coghlan
On 4 September 2016 at 08:11, Random832 wrote: > On Sat, Sep 3, 2016, at 18:06, Koos Zevenhoven wrote: >> I guess one reason I don't like bchr (nor chrb, really) is that they >> look just like a random sequence of letters in builtins, but not >> recognizable the way asdf would be. >> >> I guess I