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
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
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
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
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
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
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
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)
>>> 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