[New-bugs-announce] [issue42217] compiler: merge co_code and co_lnotab
Inada Naoki
report at bugs.python.org
Sat Oct 31 03:50:02 EDT 2020
New submission from Inada Naoki <songofacandy at gmail.com>:
co_consts are merged already, but I forget about code attributes other than co_consts.
Duplication ratio is vary by code style, but in case of logging, we can reduce 25% of them.
```
>>> data = open('Lib/logging/__pycache__/__init__.python-310.pyc', 'rb').read()
>>> import marshal
>>> x = []
>>> def walk(c):
... x.append(c.co_code)
... x.append(c.co_lnotab)
... for cc in c.co_consts:
... if hasattr(cc, 'co_code'):
... walk(cc)
...
>>> code = marshal.loads(data[16:])
>>> walk(code)
>>> len(x)
336
>>> len(set(x))
249
>>> 249/336
0.7410714285714286
```
----------
components: Interpreter Core
messages: 380045
nosy: methane
priority: normal
severity: normal
status: open
title: compiler: merge co_code and co_lnotab
type: resource usage
versions: Python 3.10
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue42217>
_______________________________________
More information about the New-bugs-announce
mailing list