[New-bugs-announce] [issue45056] compiler: Unnecessary None in co_consts

Inada Naoki report at bugs.python.org
Mon Aug 30 23:41:56 EDT 2021


New submission from Inada Naoki <songofacandy at gmail.com>:

Python 3.10 compiler adds None to co_consts even when None is not used at all.

```
$ cat x1.py
def foo():
    "docstring"
    return 42

import dis
dis.dis(foo)
print(foo.__code__.co_consts)

$ python3.9 x1.py
  3           0 LOAD_CONST               1 (42)
              2 RETURN_VALUE
('docstring', 42)

$ python3.10 x1.py
  3           0 LOAD_CONST               1 (42)
              2 RETURN_VALUE
('docstring', 42, None)
```

----------
components: Interpreter Core
keywords: 3.10regression
messages: 400683
nosy: methane
priority: normal
severity: normal
status: open
title: compiler: Unnecessary None in co_consts
versions: Python 3.10

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


More information about the New-bugs-announce mailing list