[New-bugs-announce] [issue33501] split existing optimization levels into granular options

Carl Meyer report at bugs.python.org
Mon May 14 12:18:37 EDT 2018


New submission from Carl Meyer <carl at oddbird.net>:

It doesn't make sense for e.g. docstring-stripping to necessarily imply assert-stripping. These are totally separate options, useful for separate reasons, but currently tied together in the `-O` option.

This is not just a theoretical problem; at work we must strip docstrings in production for memory reasons, but we would prefer not to strip asserts. In fact we currently lint against use of `assert` because it is stripped in production, and we replace it with our own assertion function, which is less efficient and also integrates poorly with mypy's type binder.

A better option would be to enable each of these separate optimizations with a separate command-line flag (probably a string tag passed to a single flag, e.g. `-o strip_docstrings`).

PYC filename generation will also need to include all individually-enabled optimization string tags as part of the filename.

For backwards-compatibility, the existing `-O` flags should still be supported with the same meaning they currently have; `-O` and the new granular `-o` should be additive.

(A version of this was previously proposed as a minor part of PEP 511.)

Please let me know if this proposal is of sufficient complexity that a PEP is needed instead of just an issue.

----------
messages: 316531
nosy: brett.cannon, carljm, eric.snow, lukasz.langa, ncoghlan, vstinner
priority: normal
severity: normal
status: open
title: split existing optimization levels into granular options
type: enhancement

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


More information about the New-bugs-announce mailing list