Re: Strange disassembly

2021-06-19 Thread Alan Bawden
Chris Angelico writes: >>> sys.version '3.10.0b2+ (heads/3.10:33a7a24288, Jun 9 2021, 20:47:39) [GCC 8.3.0]' >>> def chk(x): ... if not(0 < x < 10): raise Exception ... >>> dis.dis(chk) 2 0 LOAD_CONST 1 (0) 2 LOAD_FAST

Re: Strange disassembly

2021-06-19 Thread Terry Reedy
On 6/18/2021 8:13 PM, Chris Angelico wrote: On Sat, Jun 19, 2021 at 9:50 AM Terry Reedy wrote: Why are there two separate bytecode blocks for the "raise Exception"? Because one block must POP_TOP and other must not. I'd have thought that the double condition would still be evaluated as one

Re: Strange disassembly

2021-06-19 Thread Chris Angelico
On Sat, Jun 19, 2021 at 5:13 PM Rob Cliffe via Python-list wrote: > > > > On 19/06/2021 07:50, Chris Angelico wrote: > > On Sat, Jun 19, 2021 at 4:16 PM Rob Cliffe via Python-list > > wrote: > >> > >> > >> On 18/06/2021 11:04, Chris Angelico wrote: > >> sys.version > >>> '3.10.0b2+ (heads/3.1

Re: Strange disassembly

2021-06-19 Thread Rob Cliffe via Python-list
On 19/06/2021 07:50, Chris Angelico wrote: On Sat, Jun 19, 2021 at 4:16 PM Rob Cliffe via Python-list wrote: On 18/06/2021 11:04, Chris Angelico wrote: sys.version '3.10.0b2+ (heads/3.10:33a7a24288, Jun 9 2021, 20:47:39) [GCC 8.3.0]' def chk(x): ... if not(0 < x < 10): raise Excep

Re: Strange disassembly

2021-06-18 Thread Chris Angelico
On Sat, Jun 19, 2021 at 4:16 PM Rob Cliffe via Python-list wrote: > > > > On 18/06/2021 11:04, Chris Angelico wrote: > sys.version > > '3.10.0b2+ (heads/3.10:33a7a24288, Jun 9 2021, 20:47:39) [GCC 8.3.0]' > def chk(x): > > ... if not(0 < x < 10): raise Exception > > ... > dis.d

Re: Strange disassembly

2021-06-18 Thread Rob Cliffe via Python-list
On 18/06/2021 11:04, Chris Angelico wrote: sys.version '3.10.0b2+ (heads/3.10:33a7a24288, Jun 9 2021, 20:47:39) [GCC 8.3.0]' def chk(x): ... if not(0 < x < 10): raise Exception ... dis.dis(chk) 2 0 LOAD_CONST 1 (0) 2 LOAD_FAST0

Re: Strange disassembly

2021-06-18 Thread Chris Angelico
On Sat, Jun 19, 2021 at 9:50 AM Terry Reedy wrote: > > Why are there two separate bytecode blocks for the "raise Exception"? > > Because one block must POP_TOP and other must not. > > > I'd have thought that the double condition would still be evaluated as > > one thing, or at least that the jump

Re: Strange disassembly

2021-06-18 Thread Terry Reedy
On 6/18/2021 6:04 AM, Chris Angelico wrote: sys.version '3.10.0b2+ (heads/3.10:33a7a24288, Jun 9 2021, 20:47:39) [GCC 8.3.0]' def chk(x): ... if not(0 < x < 10): raise Exception 0 < x < 10 == 0 < x and x < 10, except that 'x' is evaluated once. not(_) == (not 0 < x) or (not x < 10)

Strange disassembly

2021-06-18 Thread Chris Angelico
>>> sys.version '3.10.0b2+ (heads/3.10:33a7a24288, Jun 9 2021, 20:47:39) [GCC 8.3.0]' >>> def chk(x): ... if not(0 < x < 10): raise Exception ... >>> dis.dis(chk) 2 0 LOAD_CONST 1 (0) 2 LOAD_FAST0 (x) 4 DUP_TOP