summaryrefslogtreecommitdiffstats
path: root/Lib/distutils/util.py
diff options
context:
space:
mode:
authorBrett Cannon <brett@python.org>2015-04-13 18:21:02 (GMT)
committerBrett Cannon <brett@python.org>2015-04-13 18:21:02 (GMT)
commitf299abdafa0f2b6eb7abae274861b19b361c96bc (patch)
treeafc3a2bf560e30c7725510eda3b57d71ceddba00 /Lib/distutils/util.py
parenta63cc212348e276c8ede32773313c60ff7fda651 (diff)
downloadcpython-f299abdafa0f2b6eb7abae274861b19b361c96bc.zip
cpython-f299abdafa0f2b6eb7abae274861b19b361c96bc.tar.gz
cpython-f299abdafa0f2b6eb7abae274861b19b361c96bc.tar.bz2
Issue #23731: Implement PEP 488.
The concept of .pyo files no longer exists. Now .pyc files have an optional `opt-` tag which specifies if any extra optimizations beyond the peepholer were applied.
Diffstat (limited to 'Lib/distutils/util.py')
-rw-r--r--Lib/distutils/util.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/Lib/distutils/util.py b/Lib/distutils/util.py
index 5adcac5..e423325 100644
--- a/Lib/distutils/util.py
+++ b/Lib/distutils/util.py
@@ -322,11 +322,11 @@ def byte_compile (py_files,
prefix=None, base_dir=None,
verbose=1, dry_run=0,
direct=None):
- """Byte-compile a collection of Python source files to either .pyc
- or .pyo files in a __pycache__ subdirectory. 'py_files' is a list
+ """Byte-compile a collection of Python source files to .pyc
+ files in a __pycache__ subdirectory. 'py_files' is a list
of files to compile; any files that don't end in ".py" are silently
skipped. 'optimize' must be one of the following:
- 0 - don't optimize (generate .pyc)
+ 0 - don't optimize
1 - normal optimization (like "python -O")
2 - extra optimization (like "python -OO")
If 'force' is true, all files are recompiled regardless of
@@ -438,8 +438,9 @@ byte_compile(files, optimize=%r, force=%r,
# cfile - byte-compiled file
# dfile - purported source filename (same as 'file' by default)
if optimize >= 0:
+ opt = '' if optimize == 0 else optimize
cfile = importlib.util.cache_from_source(
- file, debug_override=not optimize)
+ file, optimization=opt)
else:
cfile = importlib.util.cache_from_source(file)
dfile = file