[New-bugs-announce] [issue45974] Using walrus produces different/unoptimized bytecode

Fatih Kilic report at bugs.python.org
Fri Dec 3 17:07:41 EST 2021


New submission from Fatih Kilic <me at fklc.dev>:

So, what I mean by unoptimized bytecode is, for example when you type `a = 10 * 10`, the resulting bytecode is the following: 
```
LOAD_CONST 0 (100)
STORE_NAME 0 (a)
...
```

However, when you type, `(a := 10 * 10) == None`, the resulting bytecode is the following:
```
LOAD_CONST 0 (10)
LOAD_CONST 0 (10)
BINARY_MULTIPLY
DUP_TOP
STORE_NAME 0 (a)
...
```

I don't know if this is intentional, but shouldn't the resulting bytecode be the following:
```
LOAD_CONST 0 (100)
DUP_TOP
STORE_NAME 0 (a)
...
```

----------
components: Parser
messages: 407610
nosy: FKLC, lys.nikolaou, pablogsal
priority: normal
severity: normal
status: open
title: Using walrus produces different/unoptimized bytecode
type: behavior
versions: Python 3.10, Python 3.11, Python 3.8, Python 3.9

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue45974>
_______________________________________


More information about the New-bugs-announce mailing list