This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Using walrus produces different/unoptimized bytecode
Type: performance Stage: resolved
Components: Interpreter Core Versions: Python 3.10, Python 3.9, Python 3.8
process
Status: closed Resolution: duplicate
Dependencies: Superseder:
Assigned To: Nosy List: BTaskaya, FKLC, lys.nikolaou, pablogsal
Priority: normal Keywords:

Created on 2021-12-03 22:07 by FKLC, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (3)
msg407610 - (view) Author: Fatih Kilic (FKLC) Date: 2021-12-03 22:07
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)
...
```
msg407611 - (view) Author: Batuhan Taskaya (BTaskaya) * (Python committer) Date: 2021-12-03 22:25
See: https://bugs.python.org/issue42282 
and the reason for not backporting this: https://bugs.python.org/issue42282#msg380506
msg407612 - (view) Author: Fatih Kilic (FKLC) Date: 2021-12-03 22:34
Ah, I see. Thanks!
History
Date User Action Args
2022-04-11 14:59:53adminsetgithub: 90132
2021-12-03 22:34:23FKLCsetmessages: + msg407612
2021-12-03 22:25:53BTaskayasetstatus: open -> closed

type: behavior -> performance
components: + Interpreter Core, - Parser
versions: - Python 3.11
nosy: + BTaskaya

messages: + msg407611
resolution: duplicate
stage: resolved
2021-12-03 22:07:41FKLCcreate