New submission from Inada Naoki <songofaca...@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 <rep...@bugs.python.org> <https://bugs.python.org/issue42217> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com