[Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-11 Thread Georg Brandl
Hey all, based on the feedback so far, I revised the PEP. There is now a much simpler rule for allowed underscores, with no exceptions. This made the grammar simpler as well. --- PEP: 515 Title: Underscores in Numeric

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-11 Thread Paul Moore
On 10 February 2016 at 23:14, Steven D'Aprano wrote: > On Wed, Feb 10, 2016 at 10:53:09PM +, Paul Moore wrote: >> On 10 February 2016 at 22:20, Georg Brandl wrote: >> > This came up in python-ideas, and has met mostly positive comments, >> > although

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-11 Thread Georg Brandl
On 02/10/2016 11:42 PM, Glenn Linderman wrote: > On 2/10/2016 2:20 PM, Georg Brandl wrote: >> This came up in python-ideas, and has met mostly positive comments, >> although the exact syntax rules are up for discussion. >> >> cheers, >> Georg >> >>

Re: [Python-Dev] Time for a change of random number generator?

2016-02-11 Thread Steven D'Aprano
On Thu, Feb 11, 2016 at 01:08:41PM +1300, Greg Ewing wrote: > The Mersenne Twister is no longer regarded as quite state-of-the art > because it can get into states that produce long sequences that are > not very random. > > There is a variation on MT called WELL that has better properties > in

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-11 Thread Georg Brandl
On 02/11/2016 10:10 AM, Paul Moore wrote: > On 10 February 2016 at 23:14, Steven D'Aprano wrote: >> On Wed, Feb 10, 2016 at 10:53:09PM +, Paul Moore wrote: >>> On 10 February 2016 at 22:20, Georg Brandl wrote: >>> > This came up in python-ideas, and has

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-11 Thread Serhiy Storchaka
On 11.02.16 00:20, Georg Brandl wrote: **Group 1: liberal (like this PEP)** * D [2]_ * Perl 5 (although docs say it's more restricted) [3]_ * Rust [4]_ * Swift (although textual description says "between digits") [5]_ **Group 2: only between digits, multiple consecutive underscores** * C#

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-11 Thread Georg Brandl
On 02/11/2016 12:04 AM, Victor Stinner wrote: > It looks like the implementation https://bugs.python.org/issue26331 > only changes the Python parser. > > What about other functions converting strings to numbers at runtime > like int(str) and float(str)? Paul also asked for Decimal(str). I added

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-11 Thread Barry Warsaw
On Feb 11, 2016, at 09:22 AM, Georg Brandl wrote: >based on the feedback so far, I revised the PEP. There is now >a much simpler rule for allowed underscores, with no exceptions. >This made the grammar simpler as well. I'd be +1, but there's something missing from the PEP: what the underscores

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-11 Thread Glenn Linderman
On 2/11/2016 12:22 AM, Georg Brandl wrote: Hey all, based on the feedback so far, I revised the PEP. There is now a much simpler rule for allowed underscores, with no exceptions. This made the grammar simpler as well. +1 overall Examples:: # grouping decimal numbers by thousands

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-11 Thread Serhiy Storchaka
On 11.02.16 10:22, Georg Brandl wrote: Abstract and Rationale == This PEP proposes to extend Python's syntax so that underscores can be used in integral, floating-point and complex number literals. This is a common feature of other modern languages, and can aid readability

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-11 Thread Ethan Furman
On 02/11/2016 10:50 AM, Serhiy Storchaka wrote: > I have strong preference for more strict and simpler rule, used by > most other languages -- "only between two digits". Main arguments: > 2. Most languages use this rule. It is better to follow non-formal > standard that invent the rule that

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-11 Thread Glenn Linderman
On 2/11/2016 11:01 AM, Ethan Furman wrote: On 02/11/2016 10:50 AM, Serhiy Storchaka wrote: > I have strong preference for more strict and simpler rule, used by > most other languages -- "only between two digits". Main arguments: > 2. Most languages use this rule. It is better to follow

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-11 Thread Nick Coghlan
On 11 February 2016 at 19:59, Victor Stinner wrote: > 2016-02-11 9:11 GMT+01:00 Georg Brandl : >> On 02/11/2016 12:04 AM, Victor Stinner wrote: >>> It looks like the implementation https://bugs.python.org/issue26331 >>> only changes the Python parser.

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-11 Thread Petr Viktorin
On 02/11/2016 11:07 AM, Nick Coghlan wrote: > On 11 February 2016 at 19:59, Victor Stinner wrote: >> 2016-02-11 9:11 GMT+01:00 Georg Brandl : >>> On 02/11/2016 12:04 AM, Victor Stinner wrote: It looks like the implementation

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-11 Thread Georg Brandl
On 02/11/2016 11:17 AM, Serhiy Storchaka wrote: >> **Group 3: only between digits, only one underscore** >> >> * Ada [8]_ >> * Julia (but not in the exponent part of floats) [9]_ >> * Ruby (docs say "anywhere", in reality only between digits) [10]_ > > C++ is in this group too. > > The

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-11 Thread Steven D'Aprano
On Wed, Feb 10, 2016 at 08:41:27PM -0800, Andrew Barnert wrote: > And honestly, are you really claiming that in your opinion, "123_456_" > is worse than all of their other examples, like "1_23__4"? Yes I am, because 123_456_ looks like you've forgotten to finish typing the last group of

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-11 Thread Steven D'Aprano
On Thu, Feb 11, 2016 at 08:07:56PM +1000, Nick Coghlan wrote: > Given that str.format supports a thousands separator: > > >>> "{:,d}".format(1) > '100,000,000' > > it might be reasonable to permit "_" in place of "," in the format specifier. +1 > However, I'm not sure when you'd use

[Python-Dev] fullOfEels, assistant program for writing Python extension modules in C

2016-02-11 Thread Hugh Fisher
I've written a Python program named fullOfEels to speed up the first stages of writing Python extension modules in C. It is not a replacement for SWIG, SIP, or ctypes. It's for the case where you want to work in the opposite direction, specifying a Python API and then writing an implementation in

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-11 Thread Steven D'Aprano
On Thu, Feb 11, 2016 at 06:03:34PM +, Brett Cannon wrote: > On Thu, 11 Feb 2016 at 02:13 Steven D'Aprano wrote: > > > On Wed, Feb 10, 2016 at 08:41:27PM -0800, Andrew Barnert wrote: > > > > > And honestly, are you really claiming that in your opinion, "123_456_" > > > is

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-11 Thread Martin Panter
On 11 February 2016 at 11:12, Chris Angelico wrote: > On Thu, Feb 11, 2016 at 7:22 PM, Georg Brandl wrote: The following extensions are open for discussion: >> * Allowing underscores in string arguments to the ``Decimal`` constructor. >> It >> could be

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-11 Thread Martin Panter
On 12 February 2016 at 00:16, Steven D'Aprano wrote: > On Thu, Feb 11, 2016 at 06:03:34PM +, Brett Cannon wrote: >> On Thu, 11 Feb 2016 at 02:13 Steven D'Aprano wrote: >> >> > On Wed, Feb 10, 2016 at 08:41:27PM -0800, Andrew Barnert wrote: >> > >> >

Re: [Python-Dev] fullOfEels, assistant program for writing Python extension modules in C

2016-02-11 Thread Hugh Fisher
On Fri, Feb 12, 2016 at 3:30 AM, Nathaniel Smith wrote: > You're almost certainly aware of this, but just to double check since you > don't mention it in the email: cython is also a great tool for handling > similar situations. Not quite the same since in addition to generating

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-11 Thread Steven D'Aprano
On Thu, Feb 11, 2016 at 08:50:09PM +0200, Serhiy Storchaka wrote: > I have strong preference for more strict and simpler rule, used by most > other languages -- "only between two digits". Main arguments: > > 1. Simple rule is easier to understand, remember and recognize. I care > not about the

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-11 Thread Andrew Barnert via Python-Dev
On Thursday, February 11, 2016 10:35 AM, Jeff Hardy wrote: >On Thu, Feb 11, 2016 at 10:15 AM, Andrew Barnert via Python-Dev > wrote: > >>That's a good point: we need style rules for PEP 8. ... >>It might be simpler to write a "whitelist" than a

Re: [Python-Dev] Windows: Remove support of bytes filenames in theos module?

2016-02-11 Thread Stephen J. Turnbull
Executive summary: My experience is that having bytes APIs in the os module is very useful. But perhaps higher-level functions like os.scandir can do without (I present no arguments either way on that, just acknowledge it). Andrew Barnert writes: > Anyway, Windows CDs can't cause this

[Python-Dev] Duelling PEPs not needed [was: PEP 515: Underscores in Numeric Literals]

2016-02-11 Thread Stephen J. Turnbull
Serhiy Storchaka writes: > I suspect that my arguments can be lost [without a competing PEP]. Send Georg a patch for his PEP, that's where they belong, since only one of the two PEPs could be approved, and they would be 95% the same otherwise. If he doesn't apply it (he's allowed to move it to

Re: [Python-Dev] Time for a change of random number generator?

2016-02-11 Thread Stephen J. Turnbull
Steven D'Aprano writes: > Peters has an opinion?) but if we do change, I'd like to see the > existing random.Random moved to random.MT_Random for backwards > compatibility and compatibility with other software which uses MT. Not > necessarily saying that we have to keep it around forever

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-11 Thread Glenn Linderman
On 2/11/2016 4:16 PM, Steven D'Aprano wrote: On Thu, Feb 11, 2016 at 06:03:34PM +, Brett Cannon wrote: On Thu, 11 Feb 2016 at 02:13 Steven D'Aprano wrote: On Wed, Feb 10, 2016 at 08:41:27PM -0800, Andrew Barnert wrote: And honestly, are you really claiming that in

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-11 Thread David Mertz
Great PEP overall. We definitely don't want the restriction to grouping numbers only in threes. South Asian crore use grouping in twos. https://en.m.wikipedia.org/wiki/Crore On Feb 11, 2016 7:04 PM, "Glenn Linderman" wrote: > On 2/11/2016 4:16 PM, Steven D'Aprano wrote: >

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-11 Thread Glenn Linderman
On 2/11/2016 7:56 PM, David Mertz wrote: Great PEP overall. We definitely don't want the restriction to grouping numbers only in threes. South Asian crore use grouping in twos. https://en.m.wikipedia.org/wiki/Crore Interesting... 3 digits in the least significant group, and _then_ by

Re: [Python-Dev] Time for a change of random number generator?

2016-02-11 Thread Andrew Barnert via Python-Dev
On Thursday, February 11, 2016 7:20 PM, Stephen J. Turnbull wrote: > I think we should keep it around forever. Even my slowest colleagues > are learning that they should record their seeds and PRNG algorithms > for reproducibility's sake. :-) +1 > For that matter,

Re: [Python-Dev] Time for a change of random number generator?

2016-02-11 Thread Tim Peters
[Greg Ewing ] > The Mersenne Twister is no longer regarded as quite state-of-the art > because it can get into states that produce long sequences that are > not very random. > > There is a variation on MT called WELL that has better properties > in this regard. Does

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-11 Thread Andrew Barnert via Python-Dev
On Thursday, February 11, 2016 8:10 PM, Glenn Linderman wrote: >On 2/11/2016 7:56 PM, David Mertz wrote: > >Great PEP overall. We definitely don't want the restriction to grouping >numbers only in threes. South Asian crore use grouping in twos.

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-11 Thread Glenn Linderman
On 2/11/2016 8:22 PM, Andrew Barnert wrote: On Thursday, February 11, 2016 8:10 PM, Glenn Linderman wrote: On 2/11/2016 7:56 PM, David Mertz wrote: Great PEP overall. We definitely don't want the restriction to grouping numbers only in threes. South Asian crore use

Re: [Python-Dev] Time for a change of random number generator?

2016-02-11 Thread Chris Angelico
On Fri, Feb 12, 2016 at 3:12 PM, Andrew Barnert via Python-Dev wrote: > On Thursday, February 11, 2016 7:20 PM, Stephen J. Turnbull > wrote: > > > >> I think we should keep it around forever. Even my slowest colleagues >> are learning that they should

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-11 Thread Andrew Barnert via Python-Dev
On Feb 11, 2016, at 00:22, Georg Brandl wrote: > > Allowing underscores in string arguments to the ``Decimal`` constructor. It > could be argued that these are akin to literals, since there is no Decimal > literal available (yet). I'm +1 on this. Partly for consistency (see

Re: [Python-Dev] fullOfEels, assistant program for writing Python extension modules in C

2016-02-11 Thread Nathaniel Smith
You're almost certainly aware of this, but just to double check since you don't mention it in the email: cython is also a great tool for handling similar situations. Not quite the same since in addition to generating all the boilerplate for you it then lets you use almost-python to actually write

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-11 Thread Barry Warsaw
On Feb 11, 2016, at 05:57 PM, Georg Brandl wrote: >D'oh :) I added (hopefully) clarifying wording. I saw the diff - perfect! Thanks. -Barry ___ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-11 Thread Andrew Barnert via Python-Dev
On Feb 11, 2016, at 02:13, Steven D'Aprano wrote: > >> On Wed, Feb 10, 2016 at 08:41:27PM -0800, Andrew Barnert wrote: >> They're both presented as something the syntax allows, and neither one >> looks like something I'd ever want to write, much less promote in a >> style

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-11 Thread Georg Brandl
On 02/11/2016 05:52 PM, Steve Dower wrote: > On 11Feb2016 0651, Barry Warsaw wrote: >> On Feb 11, 2016, at 09:22 AM, Georg Brandl wrote: >> >>> based on the feedback so far, I revised the PEP. There is now >>> a much simpler rule for allowed underscores, with no exceptions. >>> This made the

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-11 Thread Steve Dower
On 11Feb2016 0651, Barry Warsaw wrote: On Feb 11, 2016, at 09:22 AM, Georg Brandl wrote: based on the feedback so far, I revised the PEP. There is now a much simpler rule for allowed underscores, with no exceptions. This made the grammar simpler as well. I'd be +1, but there's something

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-11 Thread Brett Cannon
On Thu, 11 Feb 2016 at 02:13 Steven D'Aprano wrote: > On Wed, Feb 10, 2016 at 08:41:27PM -0800, Andrew Barnert wrote: > > > And honestly, are you really claiming that in your opinion, "123_456_" > > is worse than all of their other examples, like "1_23__4"? > > Yes I am,

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-11 Thread Brett Cannon
On Thu, 11 Feb 2016 at 00:23 Georg Brandl wrote: > Hey all, > > based on the feedback so far, I revised the PEP. There is now > a much simpler rule for allowed underscores, with no exceptions. > This made the grammar simpler as well. > >

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-11 Thread Andrew Barnert via Python-Dev
On Feb 11, 2016, at 09:39, Terry Reedy wrote: > > If trailing _ is allowed, to simplify the implementation, I would like PEP 8, > while on the subject, to say something like "While trailing _s on numbers are > allowed, to simplify the implementation, they serve no purpose and

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-11 Thread Victor Stinner
2016-02-11 9:11 GMT+01:00 Georg Brandl : > On 02/11/2016 12:04 AM, Victor Stinner wrote: >> It looks like the implementation https://bugs.python.org/issue26331 >> only changes the Python parser. >> >> What about other functions converting strings to numbers at runtime >> like

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-11 Thread Chris Angelico
On Thu, Feb 11, 2016 at 7:22 PM, Georg Brandl wrote: > * Allowing underscores in string arguments to the ``Decimal`` constructor. It > could be argued that these are akin to literals, since there is no Decimal > literal available (yet). > > * Allowing underscores in string

Re: [Python-Dev] Time for a change of random number generator?

2016-02-11 Thread Robert Kern
On 2016-02-11 00:08, Greg Ewing wrote: The Mersenne Twister is no longer regarded as quite state-of-the art because it can get into states that produce long sequences that are not very random. There is a variation on MT called WELL that has better properties in this regard. Does anyone think it

[Python-Dev] Python 3.2.7 and 3.3.7

2016-02-11 Thread Georg Brandl
Hi all, I'm planning to release 3.2.7 and 3.3.7 at the end of February. There will be a release candidate on Feb 20, and the final on Feb 27, if there is no holdup. These are both security (source-only) releases. 3.2.7 will be the last release from the 3.2 series. If you know of any patches

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-11 Thread Ethan Furman
On 02/11/2016 09:19 AM, Serhiy Storchaka wrote: On 11.02.16 14:14, Georg Brandl wrote: I still think that some cases (like two of the examples in the PEP, 0b__ and 1.5_j) are worth having, and therefore a more relaxed rule is preferable. Should I write an alternative PEP for strong

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-11 Thread Serhiy Storchaka
On 11.02.16 14:14, Georg Brandl wrote: On 02/11/2016 11:17 AM, Serhiy Storchaka wrote: **Group 3: only between digits, only one underscore** * Ada [8]_ * Julia (but not in the exponent part of floats) [9]_ * Ruby (docs say "anywhere", in reality only between digits) [10]_ C++ is in this

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-11 Thread Terry Reedy
On 2/11/2016 2:45 AM, Georg Brandl wrote: Thanks for grabbing this issue and moving it forward. I will like being about to write or read 200_000_000 and be sure I an right without counting 0s. Based on the feedback so far, I have an easier rule in mind that I will base the next PEP

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-11 Thread Georg Brandl
On 02/11/2016 06:19 PM, Serhiy Storchaka wrote: >> Thanks for the alternate patch. I used the two-function approach you took >> in ast.c for my latest revision. >> >> I still think that some cases (like two of the examples in the PEP, >> 0b__ and 1.5_j) are worth having, and therefore a

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-11 Thread Serhiy Storchaka
On 11.02.16 19:40, Georg Brandl wrote: On 02/11/2016 06:19 PM, Serhiy Storchaka wrote: Thanks for the alternate patch. I used the two-function approach you took in ast.c for my latest revision. I still think that some cases (like two of the examples in the PEP, 0b__ and 1.5_j) are

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-11 Thread Andrew Barnert via Python-Dev
On Feb 11, 2016, at 10:15, Andrew Barnert via Python-Dev wrote: > > That's a good point: we need style rules for PEP 8. One more point: should the tutorial mention underscores? It looks like the intro docs for a lot of the other languages do. And it would only take one

Re: [Python-Dev] PEP 515: Underscores in Numeric Literals

2016-02-11 Thread Jeff Hardy
On Thu, Feb 11, 2016 at 10:15 AM, Andrew Barnert via Python-Dev < python-dev@python.org> wrote: > On Feb 11, 2016, at 09:39, Terry Reedy wrote: > > > > If trailing _ is allowed, to simplify the implementation, I would like > PEP 8, while on the subject, to say something like