[New-bugs-announce] [issue36466] Adding a way to strip annotations from compiled bytecode

cary report at bugs.python.org
Thu Mar 28 22:11:47 EDT 2019


New submission from cary <cary at dropbox.com>:

Similar to how `-OO` currently strips docstrings from compiled bytecode, it would be nice if there were a way to strip annotations as well to further compact the bytecode.

Attached is my initial attempt. From some simple manual testing, Python with this patch applied will generate the same bytecode (verified with `marshal` and `dis`) for two files with the same logic, but with annotations manually removed from one of them.

This will probably need some new flag/optimization level rather than relying on `-OO` (as it would be a breaking change).

Open to initial reviews of the patch and idea in general, and suggestions on how to best thread the option through to the module.

----------
components: Interpreter Core
files: strip_annotations.patch
keywords: patch
messages: 339091
nosy: cary
priority: normal
severity: normal
status: open
title: Adding a way to strip annotations from compiled bytecode
type: enhancement
Added file: https://bugs.python.org/file48237/strip_annotations.patch

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


More information about the New-bugs-announce mailing list