[Python-Dev] reversed enumerate

2020-04-02 Thread Stephen J. Turnbull
Ilya Kamenshchikov writes: > I needed reversed(enumerate(x: list)) in my code, def reversed_enumerated_list(l): return zip(reversed(range(len(l)), reversed(l)) > and have discovered that it wound't work. I wouldn't have expected it to, because enumerate's result is unbounded. But I'm

[Python-Dev] Re: PEP 616 -- String methods to remove prefixes and suffixes

2020-04-02 Thread Nick Coghlan
On Sat., 28 Mar. 2020, 8:39 am Guido van Rossum, wrote: > On Fri, Mar 27, 2020 at 3:29 PM Dennis Sweeney < > sweeney.dennis...@gmail.com> wrote: > >> > If I saw that in a code review I'd flag it for non-obviousness. One >> should >> > use 'string != new_string' unless there is severe pressure to

[Python-Dev] Re: PEP 617: New PEG parser for CPython

2020-04-02 Thread Guido van Rossum
On Thu, Apr 2, 2020 at 2:55 PM Pablo Galindo Salgado wrote: > > About the migration, can I ask who is going to (help > to) fix projects which rely on the AST? > > Whoops, I send the latest email before finishing it by mistake. Here is > the extended version of the answer: > > I think there is a

[Python-Dev] Re: PEP 617: New PEG parser for CPython

2020-04-02 Thread Victor Stinner
Sorry, I was referring to *ambiguous* grammar rules. Extract of the PEP: "Unlike LL(1) parsers PEG-based parsers cannot be ambiguous: if a string parses, it has exactly one valid parse tree. This means that a PEG-based parser cannot suffer from the ambiguity problems described in the previous

[Python-Dev] Re: PEP 617: New PEG parser for CPython

2020-04-02 Thread Pablo Galindo Salgado
> Just to clarify, this means that 3.9 will ship with the PEG parser as default, > right? If so, this would be a new feature, post beta. Since that is counter > to our > general policy, we would need to get explicit RM approval for such a change. The idea is merging it *before beta* and make

[Python-Dev] Re: PEP 617: New PEG parser for CPython

2020-04-02 Thread Barry Warsaw
On Apr 2, 2020, at 13:07, Pablo Galindo Salgado wrote: > >> Just to clarify, this means that 3.9 will ship with the PEG parser as >> default, >> right? If so, this would be a new feature, post beta. Since that is >> counter to our >> general policy, we would need to get explicit RM approval

[Python-Dev] Re: PEP 616 -- String methods to remove prefixes and suffixes

2020-04-02 Thread Nick Coghlan
On Thu., 2 Apr. 2020, 8:30 am Victor Stinner, wrote: > I suggest you to wait one more week to let other people comment the > PEP. After this delay, if you consider that the PEP is ready for > pronouncement, you can submit it to the Steering Council, right. > Note that the submission to the

[Python-Dev] Re: PEP 617: New PEG parser for CPython

2020-04-02 Thread Batuhan Taskaya
Wonderful news! I'm really excited to see what is coming alongside this flexible parser. On Thu, Apr 2, 2020 at 9:16 PM Guido van Rossum wrote: > > Since last fall's core sprint in London, Pablo Galindo Salgado, Lysandros > Nikolaou and myself have been working on a new parser for CPython. We

[Python-Dev] Re: PEP 617: New PEG parser for CPython

2020-04-02 Thread Paul Moore
On Thu, 2 Apr 2020 at 19:20, Guido van Rossum wrote: > > Since last fall's core sprint in London, Pablo Galindo Salgado, Lysandros > Nikolaou and myself have been working on a new parser for CPython. We are now > far enough along that we present a PEP we've written: > >

[Python-Dev] Re: Debug C++

2020-04-02 Thread Antonio Cavallo
You can also attach gdb to a running (python) process .. but the interpreter needs to have the symbol table (eg. not stripped). I gave a presentation few years back on this exact topic (sorry for the quality, I was very in-experienced).

[Python-Dev] Re: PEP 617: New PEG parser for CPython

2020-04-02 Thread Nathaniel Smith
On Thu, Apr 2, 2020 at 2:48 PM Pablo Galindo Salgado wrote: > > > About the migration, can I ask who is going to (help to) fix projects > which rely on the AST? > > I think you misunderstood: The AST is exactly the same as the old and the new > parser. The only > the thing that the new parser

[Python-Dev] Re: PEP 617: New PEG parser for CPython

2020-04-02 Thread Guido van Rossum
On Thu, Apr 2, 2020 at 4:20 PM Nathaniel Smith wrote: > On Thu, Apr 2, 2020 at 2:48 PM Pablo Galindo Salgado > wrote: > > > > > About the migration, can I ask who is going to (help to) fix projects > > which rely on the AST? > > > > I think you misunderstood: The AST is exactly the same as the

[Python-Dev] Re: PEP 617: New PEG parser for CPython

2020-04-02 Thread Ivan Levkivskyi
These are good news. I think the new parser is indeed both simpler and more flexible - great! -- Ivan On Thu, 2 Apr 2020 at 19:19, Guido van Rossum wrote: > Since last fall's core sprint in London, Pablo Galindo Salgado, Lysandros > Nikolaou and myself have been working on a new parser for

[Python-Dev] Re: PEP 617: New PEG parser for CPython

2020-04-02 Thread Guido van Rossum
On Thu, Apr 2, 2020 at 12:43 PM Paul Moore wrote: > On Thu, 2 Apr 2020 at 19:20, Guido van Rossum wrote: > > > > Since last fall's core sprint in London, Pablo Galindo Salgado, > Lysandros Nikolaou and myself have been working on a new parser for > CPython. We are now far enough along that we

[Python-Dev] Re: PEP 617: New PEG parser for CPython

2020-04-02 Thread Greg Ewing
On 3/04/20 10:33 am, Victor Stinner wrote: I also like the fact that PEG is deterministic, whereas LL(1) parsers are not. Where do you get that LL(1) parsers are not deterministic? That's news to me! -- Greg ___ Python-Dev mailing list --

[Python-Dev] Re: PEP 617: New PEG parser for CPython

2020-04-02 Thread Pablo Galindo Salgado
> About the migration, can I ask who is going to (help to) fix projects which rely on the AST? I think you misunderstood: The AST is exactly the same as the old and the new parser. The only the thing that the new parser does is not generate an immediate CST (Concrete Syntax Tree) and that is

[Python-Dev] Re: PEP 617: New PEG parser for CPython

2020-04-02 Thread Guido van Rossum
On Thu, Apr 2, 2020 at 1:21 PM Barry Warsaw wrote: > On Apr 2, 2020, at 13:07, Pablo Galindo Salgado > wrote: > > > >> Just to clarify, this means that 3.9 will ship with the PEG parser as > default, > >> right? If so, this would be a new feature, post beta. Since that is > counter to our >

[Python-Dev] Re: PEP 617: New PEG parser for CPython

2020-04-02 Thread Barry Warsaw
Great to see this new work pay off! On Apr 2, 2020, at 11:10, Guido van Rossum wrote: > 2. After Python 3.9 Beta 1 the default parser will be the new parser. Just to clarify, this means that 3.9 will ship with the PEG parser as default, right? If so, this would be a new feature, post beta.

[Python-Dev] Re: PEP 617: New PEG parser for CPython

2020-04-02 Thread Pablo Galindo Salgado
> About the migration, can I ask who is going to (help to) fix projects which rely on the AST? Whoops, I send the latest email before finishing it by mistake. Here is the extended version of the answer: I think there is a misunderstanding here: The new parser generates the same AST as the old

[Python-Dev] Re: PEP 617: New PEG parser for CPython

2020-04-02 Thread Victor Stinner
Hi, It's great to see that you finally managed to come up with a PEP, this work becomes concrete: congrats! I started to read the PEP, and it's really well written! I heard that LL(1) parsers have limits, but this PEP explains very well that the current Python grammar was already "hacked" to

[Python-Dev] Re: PEP 617: New PEG parser for CPython

2020-04-02 Thread Greg Ewing
On 3/04/20 7:10 am, Guido van Rossum wrote: Since last fall's core sprint in London, Pablo Galindo Salgado, Lysandros Nikolaou and myself have been working on a new parser for CPython. We are now far enough along that we present a PEP we've written: https://www.python.org/dev/peps/pep-0617/

[Python-Dev] Re: PEP 617: New PEG parser for CPython

2020-04-02 Thread Matt Billenstein via Python-Dev
On Thu, Apr 02, 2020 at 05:17:31PM -0700, Guido van Rossum wrote: > On Thu, Apr 2, 2020 at 4:20 PM Nathaniel Smith wrote: > > If the AST is supposed to be the same, then would it make sense to > temporarily – maybe just during the alpha/beta period – always run > *both* parsers and

[Python-Dev] Re: PEP 617: New PEG parser for CPython

2020-04-02 Thread Matt Billenstein via Python-Dev
On Thu, Apr 02, 2020 at 08:57:30PM -0700, Guido van Rossum wrote: > On Thu, Apr 2, 2020 at 7:55 PM Matt Billenstein wrote: > > Even just running it in a dev build against the corpus of the top few > thousand packages on pypi might give enough confidence -- I had a script > to

[Python-Dev] Re: PEP 617: New PEG parser for CPython

2020-04-02 Thread Guido van Rossum
Le ven. 3 avr. 2020 à 02:58, Greg Ewing a écrit : > On 3/04/20 10:33 am, Victor Stinner wrote: > > I also like the fact that PEG is deterministic, whereas > > LL(1) parsers are not. > > Where do you get that LL(1) parsers are not deterministic? > That's news to me! On Thu, Apr 2, 2020 at 6:15

[Python-Dev] Re: PEP 617: New PEG parser for CPython

2020-04-02 Thread Greg Ewing
On 3/04/20 3:22 pm, Guido van Rossum wrote: This allows more freedom in designing a grammar. For example, it would let a language designer solve the "dangling else" problem from the Wikipedia page, by writing the form including the "else" clause first . I'm inclined to think that such

[Python-Dev] Re: PEP 617: New PEG parser for CPython

2020-04-02 Thread Guido van Rossum
On Thu, Apr 2, 2020 at 7:55 PM Matt Billenstein wrote: > On Thu, Apr 02, 2020 at 05:17:31PM -0700, Guido van Rossum wrote: > > On Thu, Apr 2, 2020 at 4:20 PM Nathaniel Smith wrote: > > > > If the AST is supposed to be the same, then would it make sense to > > temporarily – maybe just

[Python-Dev] Re: PEP 617: New PEG parser for CPython

2020-04-02 Thread Greg Ewing
On 3/04/20 2:13 pm, Victor Stinner wrote: "Unlike LL(1) parsers PEG-based parsers cannot be ambiguous: if a string parses, it has exactly one valid parse tree. This means that a PEG-based parser cannot suffer from the ambiguity problems described in the previous section." That paragraph seems

[Python-Dev] Re: reversed enumerate

2020-04-02 Thread Ilya Kamenshchikov
Re: st...@pearwood.info > It isn't really well-defined, since enumerate can operate on infinite > iterators, and you cannot reverse an infinite stream. It is well defined on any iterable that itself is reversible and has defined length. For standard types that's lists, strings, dictionary

[Python-Dev] Re: Python-Dev Digest, Vol 201, Issue 1

2020-04-02 Thread Ilya Kamenshchikov
One potentially serious question: what should `enumerate.__reversed__` > do when given a starting value? > reversed(enumerate('abc', 1)) > Should that yield...? > # treat the start value as a start value > (1, 'c'), (0, 'b'), (-1, 'a') > # treat the start value as an end value >

[Python-Dev] PEP 617: New PEG parser for CPython

2020-04-02 Thread Guido van Rossum
Since last fall's core sprint in London, Pablo Galindo Salgado, Lysandros Nikolaou and myself have been working on a new parser for CPython. We are now far enough along that we present a PEP we've written: https://www.python.org/dev/peps/pep-0617/ Hopefully the PEP speaks for itself. We are

[Python-Dev] Re: Moving threadstate to thread-local storage.

2020-04-02 Thread Petr Viktorin
On 2020-03-24 16:31, Mark Shannon wrote: Hi, As an experiment, I thought I would try moving the thread state (what you get from _PyThreadState_GET() ) to TLS. https://github.com/python/cpython/compare/master...markshannon:threadstate_in_tls It works, passing all the tests, and seems