[Python-Dev] Re: Critique of PEP 622 (Structural Pattern Matching)

2020-08-17 Thread Mark Shannon
On 15/08/2020 11:06 pm, Guido van Rossum wrote: On Fri, Aug 14, 2020 at 11:42 PM Steven D'Aprano > wrote: On Sat, Aug 15, 2020 at 12:36:25AM +1000, Chris Angelico wrote: > Do you have anything new to add to the discussion, or is this 2000 > lines of

[Python-Dev] Re: PEP 622 questions

2020-08-17 Thread Mark Shannon
On 16/08/2020 8:23 pm, Jean Abou Samra wrote: Hi there, As a poor user, I am extremely excited about the possibilities PEP 622 (structural pattern matching) opens. I'd like to ask a few questions. OOI, what possibilities? I'm genuinely interested know what problems PEP 622 would solve for

[Python-Dev] Re: PEP 622 questions

2020-08-17 Thread Mark Shannon
On 16/08/2020 9:41 pm, Guido van Rossum wrote: On Sun, Aug 16, 2020 at 12:37 PM Jean Abou Samra > wrote: Hi there, As a poor user, I am extremely excited about the possibilities PEP 622 (structural pattern matching) opens. I'd like to ask a few quest

[Python-Dev] Re: Critique of PEP 622 (Structural Pattern Matching)

2020-08-17 Thread Mark Shannon
Hi Chris, On 14/08/2020 3:36 pm, Chris Angelico wrote: On Sat, Aug 15, 2020 at 12:32 AM Mark Shannon wrote: Hi all, I've written up a critique of PEP 622. Rather than dump a 2000 line email on you all, I've made a git repo. https://github.com/markshannon/pep622-critique I started reading

[Python-Dev] Re: Critique of PEP 622 (Structural Pattern Matching)

2020-08-17 Thread Henk-Jaap Wagenaar
On Mon, 17 Aug 2020 at 11:30, Mark Shannon wrote: > > I would also bring you attention to my rigorous analysis of the possible > application to PEP 622 the entirety of CPython. > If I have made any mistakes there, I'd be happy to correct them. > > You say "I've elided a lot of complex logic int c

[Python-Dev] Re: Critique of PEP 622 (Structural Pattern Matching)

2020-08-17 Thread Mark Shannon
On 17/08/2020 1:13 pm, Henk-Jaap Wagenaar wrote: On Mon, 17 Aug 2020 at 11:30, Mark Shannon > wrote: I would also bring you attention to my rigorous analysis of the possible application to PEP 622 the entirety of CPython. If I have made any mistakes ther

[Python-Dev] Re: Critique of PEP 622 (Structural Pattern Matching)

2020-08-17 Thread Henk-Jaap Wagenaar
Thanks for having a look! The example now looks like (looking at int case only, same applies to UID): case int(): if value < 0: try: self._fp.write(struct.pack('>Bq', 0x13, value)) except struct.error: rais

[Python-Dev] Re: Critique of PEP 622 (Structural Pattern Matching)

2020-08-17 Thread Marat Khalili
Hi all, I started reading it. You're saying the same things that everyone else has said, so I stopped reading. Do you have anything new to add to the discussion, or is this 2000 lines of rehash? I'm new to the subject, and I find the rehash of everything that has been said on the subject use

[Python-Dev] Re: Critique of PEP 622 (Structural Pattern Matching)

2020-08-17 Thread Mark Shannon
On 17/08/2020 3:08 pm, Henk-Jaap Wagenaar wrote: Thanks for having a look! The example now looks like (looking at int case only, same applies to UID):         case int():             if value < 0:                 try:                     self._fp.write(struct.pack('>Bq', 0x13, value))  

[Python-Dev] Re: Critique of PEP 622 (Structural Pattern Matching)

2020-08-17 Thread Henk-Jaap Wagenaar
> > That would work, but would be slower for the reference implementation > due to the repeated `isinstance(value, int)` checks. > If you wanted to avoid that you could use match/case inside the "case int()" instead, i.e.: case int(): match value: case _ if value < 8: // do thin

[Python-Dev] Re: Critique of PEP 622 (Structural Pattern Matching)

2020-08-17 Thread Guido van Rossum
On Mon, Aug 17, 2020 at 8:11 AM Mark Shannon wrote: > > > On 17/08/2020 3:08 pm, Henk-Jaap Wagenaar wrote: > > Thanks for having a look! The example now looks like (looking at int > > case only, same applies to UID): > > > > case int(): > > if value < 0: > >

[Python-Dev] Re: Critique of PEP 622 (Structural Pattern Matching)

2020-08-17 Thread Baptiste Carvello
Le 14/08/2020 à 16:24, Mark Shannon a écrit : > > https://github.com/markshannon/pep622-critique Hi all, reading through this made me think of 3 ideas which I think are new [1]. 2 of them are about the Value Pattern question, the last one is a small nit about the Django example. * the critique

[Python-Dev] Re: PEP 622 questions

2020-08-17 Thread Jean Abou Samra
Hi, Thanks for your reply! > Le 16 août 2020 à 22:41, Guido van Rossum a écrit : > >> On Sun, Aug 16, 2020 at 12:37 PM Jean Abou Samra wrote: >> Hi there, >> >> As a poor user, I am extremely excited about the possibilities PEP 622 >> (structural pattern matching) opens. I'd like to ask a fe

[Python-Dev] Re: PEP 622 questions

2020-08-17 Thread Jean Abou Samra
> OOI, what possibilities? I'm genuinely interested know what problems PEP 622 > would solve for you. It's somehow the same use case as Oscar Benjamin's: transform algebraic expressions (the goal being to calculate them step by step -- still under development). You have a series of rules to ap

[Python-Dev] Re: Critique of PEP 622 (Structural Pattern Matching)

2020-08-17 Thread Jean Abou Samra
> (the example with changing HTTP_OK value is downright horrifying). As was just mentioned by Guido in another thread, there is a SyntaxWarning to alert you. > This leads to the idea that, if a special syntax if eventually used for Value > Patterns, using the comparison operator in it might be

[Python-Dev] Re: PEP 622 questions

2020-08-17 Thread Guido van Rossum
On Mon, Aug 17, 2020 at 10:04 AM Jean Abou Samra wrote: [Jean] > Finally, was as-based syntax considered as an alternative to walrus >> patterns, that is, PATTERN as NAME instead of NAME := PATTERN, as we have >> in the try statement? Given the extensive discussion, I guess it might have >> been

[Python-Dev] Re: PEP 622 questions

2020-08-17 Thread Guido van Rossum
On Mon, Aug 17, 2020 at 3:37 AM Mark Shannon wrote: > > > On 16/08/2020 9:41 pm, Guido van Rossum wrote: > > On Sun, Aug 16, 2020 at 12:37 PM Jean Abou Samra > > wrote: > > Also, I see potential for a caveat: > > > > match number: > >case int: # missing