8000 bpo-2506: Add mechanism to disable optimizations by pablogsal · Pull Request #22027 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-2506: Add mechanism to disable optimizations #22027

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fixup! bpo-2506: Add -X noopt command line option
  • Loading branch information
pablogsal committed Aug 31, 2020
commit 1b9e8f62bbee63baab24b98af0ed85a75f3f5335
6 changes: 3 additions & 3 deletions Doc/library/importlib.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1430,9 +1430,9 @@ an :term:`importer`.
of *optimization* can only be alphanumeric, else :exc:`ValueError` is raised.

The *noopt* parameter is used to specify if compiler optimization are
disabled. If it is true, *optimization* is ignored and ``.noopt`` suffix is
used (ex: ``baz.cpython-32.noopt.pyc``). If it is ``None``, use
``sys.flags.noopt`` value.
disabled. If it is true, disable compiler optimizations, *optimization* is
ignored and ``.noopt`` suffix is used (ex: ``baz.cpython-32.noopt.pyc``). If
it is ``None``, use ``sys.flags.noopt`` value.

The *debug_override* parameter is deprecated and can be used to override
the system's value for ``__debug__``. A ``True`` value is the equivalent of
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/py_compile.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ byte-code cache files in the directory containing the source code.
Exception raised when an error occurs while attempting to compile the file.


.. function:: compile(file, cfile=None, dfile=None, doraise=False, optimize=-1, invalidation_mode=PycInvalidationMode.TIMESTAMP, quiet=0)
.. function:: compile(file, cfile=None, dfile=None, doraise=False, optimize=-1, invalidation_mode=PycInvalidationMode.TIMESTAMP, quiet=0, noopt=None)

Compile a source file to byte-code and write out the byte-code cache file.
The source code is loaded from the file named *file*. The byte-code is
Expand Down
2 changes: 1 addition & 1 deletion Include/compile.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ PyAPI_FUNC(int) _PyAST_Optimize(struct _mod *, PyArena *arena, _PyASTOptimizeSta
/* This doesn't need to match anything */
#define Py_fstring_input 800

/* Value of 'optimize' to deactivate all optimizations */
/* Value of 'optimize' to disable all optimizations */
#define _PyCompiler_disable_all_optimizations -2

#endif /* !Py_COMPILE_H */
2 changes: 1 addition & 1 deletion Include/cpython/initconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ typedef struct {

If equal to 1, enable compiler optimizations.

Set to 0 by -X noopt. */
Set to 0 by -X noopt. It's default value is 1 */
int optimize;

} PyConfig;
Expand Down
1 change: 1 addition & 0 deletions Lib/test/test_dis.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Minimal tests for dis module

from test import support
from test.support import captured_stdout
from test.support.bytecode_helper import BytecodeTestCase
import unittest
Expand Down
4 changes: 2 additions & 2 deletions Lib/test/test_embed.py
Original file line number Diff line number Diff line change
Expand Up @@ -1068,7 +1068,7 @@ def test_init_parse_argv(self):
config = {
'parse_argv': 1,
'argv': ['-c', 'arg1', '-v', 'arg3'],
'orig_argv': ['./argv0', '-E', '-c', 'pass', 'arg1', '-v', 'arg3'],
'orig_argv': ['./argv0', '-E', '-X', 'noopt', '-c', 'pass', 'arg1', '-v', 'arg3'],
'program_name': './argv0',
'run_command': 'pass\n',
'use_environment': 0,
Expand All @@ -1084,7 +1084,7 @@ def test_init_dont_parse_argv(self):
config = {
'parse_argv': 0,
'argv': ['./argv0', '-E', '-X', 'noopt', '-c', 'pass', 'arg1', '-v', 'arg3'],
'orig_argv': ['./argv0', '-E', '-c', 'pass', 'arg1', '-v', 'arg3'],
'orig_argv': ['./argv0', '-E', '-X', 'noopt', '-c', 'pass', 'arg1', '-v', 'arg3'],
'program_name': './argv0',
}
self.check_all_configs("test_init_dont_parse_argv", config, pre_config,
3F9C Expand Down
0