Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(38451)

Side by Side Diff: Doc/library/compileall.rst

Issue 16104: Use multiprocessing in compileall script
Patch Set: Created 5 years ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | Lib/compileall.py » ('j') | Lib/compileall.py » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 :mod:`compileall` --- Byte-compile Python libraries 1 :mod:`compileall` --- Byte-compile Python libraries
2 =================================================== 2 ===================================================
3 3
4 .. module:: compileall 4 .. module:: compileall
5 :synopsis: Tools for byte-compiling all Python source files in a directory tr ee. 5 :synopsis: Tools for byte-compiling all Python source files in a directory tr ee.
6 6
7 7
8 This module provides some utility functions to support installing Python 8 This module provides some utility functions to support installing Python
9 libraries. These functions compile Python source files in a directory tree. 9 libraries. These functions compile Python source files in a directory tree.
10 This module can be used to create the cached byte-code files at library 10 This module can be used to create the cached byte-code files at library
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 is to write files to their :pep:`3147` locations and names, which allows 66 is to write files to their :pep:`3147` locations and names, which allows
67 byte-code files from multiple versions of Python to coexist. 67 byte-code files from multiple versions of Python to coexist.
68 68
69 .. cmdoption:: -r 69 .. cmdoption:: -r
70 70
71 Control the maximum recursion level for subdirectories. 71 Control the maximum recursion level for subdirectories.
72 If this is given, then ``-l`` option will not be taken into account. 72 If this is given, then ``-l`` option will not be taken into account.
73 :program:`python -m compileall <directory> -r 0` is equivalent to 73 :program:`python -m compileall <directory> -r 0` is equivalent to
74 :program:`python -m compileall <directory> -l`. 74 :program:`python -m compileall <directory> -l`.
75 75
76 .. cmdoption:: -j N
77
78 Use *N* workers to compile the files within the given directory.
79 If ``0`` is used, then the result of :func:`os.cpu_count()`
80 will be used.
76 81
77 .. versionchanged:: 3.2 82 .. versionchanged:: 3.2
78 Added the ``-i``, ``-b`` and ``-h`` options. 83 Added the ``-i``, ``-b`` and ``-h`` options.
79 84
80 .. versionchanged:: 3.5 85 .. versionchanged:: 3.5
81 Added the ``-r`` option. 86 Added the ``-j`` and ``-r`` options.
87
82 88
83 There is no command-line option to control the optimization level used by the 89 There is no command-line option to control the optimization level used by the
84 :func:`compile` function, because the Python interpreter itself already 90 :func:`compile` function, because the Python interpreter itself already
85 provides the option: :program:`python -O -m compileall`. 91 provides the option: :program:`python -O -m compileall`.
86 92
87 Public functions 93 Public functions
88 ---------------- 94 ----------------
89 95
90 .. function:: compile_dir(dir, maxlevels=10, ddir=None, force=False, rx=None, qu iet=False, legacy=False, optimize=-1) 96 .. function:: compile_dir(dir, maxlevels=10, ddir=None, force=False, rx=None, qu iet=False, legacy=False, optimize=-1, workers=1)
91 97
92 Recursively descend the directory tree named by *dir*, compiling all :file:`. py` 98 Recursively descend the directory tree named by *dir*, compiling all :file:`. py`
93 files along the way. 99 files along the way.
94 100
95 The *maxlevels* parameter is used to limit the depth of the recursion; it 101 The *maxlevels* parameter is used to limit the depth of the recursion; it
96 defaults to ``10``. 102 defaults to ``10``.
97 103
98 If *ddir* is given, it is prepended to the path to each file being compiled 104 If *ddir* is given, it is prepended to the path to each file being compiled
99 for use in compilation time tracebacks, and is also compiled in to the 105 for use in compilation time tracebacks, and is also compiled in to the
100 byte-code file, where it will be used in tracebacks and other messages in 106 byte-code file, where it will be used in tracebacks and other messages in
(...skipping 11 matching lines...) Expand all
112 occur. 118 occur.
113 119
114 If *legacy* is true, byte-code files are written to their legacy locations 120 If *legacy* is true, byte-code files are written to their legacy locations
115 and names, which may overwrite byte-code files created by another version of 121 and names, which may overwrite byte-code files created by another version of
116 Python. The default is to write files to their :pep:`3147` locations and 122 Python. The default is to write files to their :pep:`3147` locations and
117 names, which allows byte-code files from multiple versions of Python to 123 names, which allows byte-code files from multiple versions of Python to
118 coexist. 124 coexist.
119 125
120 *optimize* specifies the optimization level for the compiler. It is passed t o 126 *optimize* specifies the optimization level for the compiler. It is passed t o
121 the built-in :func:`compile` function. 127 the built-in :func:`compile` function.
128
129 The argument *workers* specifies how many workers are used to
130 compile files in parallel. The default is to not use multiple workers.
131 If the platform can't use multiple workers and *workers* argument is given,
132 then a :exc:`NotImplementedError` will be raised.
133 If *workers* is lower than ``0``, a :exc:`ValueError` will be raised.
122 134
123 .. versionchanged:: 3.2 135 .. versionchanged:: 3.2
124 Added the *legacy* and *optimize* parameter. 136 Added the *legacy* and *optimize* parameter.
125 137
138 .. versionchanged:: 3.5
139 Added the *workers* parameter.
140
126 141
127 .. function:: compile_file(fullname, ddir=None, force=False, rx=None, quiet=Fals e, legacy=False, optimize=-1) 142 .. function:: compile_file(fullname, ddir=None, force=False, rx=None, quiet=Fals e, legacy=False, optimize=-1)
128 143
129 Compile the file with path *fullname*. 144 Compile the file with path *fullname*.
130 145
131 If *ddir* is given, it is prepended to the path to the file being compiled 146 If *ddir* is given, it is prepended to the path to the file being compiled
132 for use in compilation time tracebacks, and is also compiled in to the 147 for use in compilation time tracebacks, and is also compiled in to the
133 byte-code file, where it will be used in tracebacks and other messages in 148 byte-code file, where it will be used in tracebacks and other messages in
134 cases where the source file does not exist at the time the byte-code file is 149 cases where the source file does not exist at the time the byte-code file is
135 executed. 150 executed.
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 189
175 # Perform same compilation, excluding files in .svn directories. 190 # Perform same compilation, excluding files in .svn directories.
176 import re 191 import re
177 compileall.compile_dir('Lib/', rx=re.compile(r'[/\\][.]svn'), force=True) 192 compileall.compile_dir('Lib/', rx=re.compile(r'[/\\][.]svn'), force=True)
178 193
179 194
180 .. seealso:: 195 .. seealso::
181 196
182 Module :mod:`py_compile` 197 Module :mod:`py_compile`
183 Byte-compile a single source file. 198 Byte-compile a single source file.
OLDNEW
« no previous file with comments | « no previous file | Lib/compileall.py » ('j') | Lib/compileall.py » ('J')

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+