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

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

Issue 16104: Use multiprocessing in compileall script
Patch Set: Created 5 years, 6 months 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 Read the file ``list`` and add each line that it contains to the list of 57 Read the file ``list`` and add each line that it contains to the list of
58 files and directories to compile. If ``list`` is ``-``, read lines from 58 files and directories to compile. If ``list`` is ``-``, read lines from
59 ``stdin``. 59 ``stdin``.
60 60
61 .. cmdoption:: -b 61 .. cmdoption:: -b
62 62
63 Write the byte-code files to their legacy locations and names, which may 63 Write the byte-code files to their legacy locations and names, which may
64 overwrite byte-code files created by another version of Python. The default 64 overwrite byte-code files created by another version of Python. The default
65 is to write files to their :pep:`3147` locations and names, which allows 65 is to write files to their :pep:`3147` locations and names, which allows
66 byte-code files from multiple versions of Python to coexist. 66 byte-code files from multiple versions of Python to coexist.
67
68 .. cmdoption:: -j
69
70 Use multiple processes to compile the given directory.
67 71
68 .. versionchanged:: 3.2 72 .. versionchanged:: 3.2
69 Added the ``-i``, ``-b`` and ``-h`` options. 73 Added the ``-i``, ``-b`` and ``-h`` options.
70 74
75 .. versionchanged:: 3.5
76 Added the ``-j`` option.
77
71 There is no command-line option to control the optimization level used by the 78 There is no command-line option to control the optimization level used by the
72 :func:`compile` function, because the Python interpreter itself already 79 :func:`compile` function, because the Python interpreter itself already
73 provides the option: :program:`python -O -m compileall`. 80 provides the option: :program:`python -O -m compileall`.
74 81
75 Public functions 82 Public functions
76 ---------------- 83 ----------------
77 84
78 .. function:: compile_dir(dir, maxlevels=10, ddir=None, force=False, rx=None, qu iet=False, legacy=False, optimize=-1) 85 .. function:: compile_dir(dir, maxlevels=10, ddir=None, force=False, rx=None, qu iet=False, legacy=False, optimize=-1, processes=None)
79 86
80 Recursively descend the directory tree named by *dir*, compiling all :file:`. py` 87 Recursively descend the directory tree named by *dir*, compiling all :file:`. py`
81 files along the way. 88 files along the way.
82 89
83 The *maxlevels* parameter is used to limit the depth of the recursion; it 90 The *maxlevels* parameter is used to limit the depth of the recursion; it
84 defaults to ``10``. 91 defaults to ``10``.
85 92
86 If *ddir* is given, it is prepended to the path to each file being compiled 93 If *ddir* is given, it is prepended to the path to each file being compiled
87 for use in compilation time tracebacks, and is also compiled in to the 94 for use in compilation time tracebacks, and is also compiled in to the
88 byte-code file, where it will be used in tracebacks and other messages in 95 byte-code file, where it will be used in tracebacks and other messages in
(...skipping 11 matching lines...) Expand all
100 occur. 107 occur.
101 108
102 If *legacy* is true, byte-code files are written to their legacy locations 109 If *legacy* is true, byte-code files are written to their legacy locations
103 and names, which may overwrite byte-code files created by another version of 110 and names, which may overwrite byte-code files created by another version of
104 Python. The default is to write files to their :pep:`3147` locations and 111 Python. The default is to write files to their :pep:`3147` locations and
105 names, which allows byte-code files from multiple versions of Python to 112 names, which allows byte-code files from multiple versions of Python to
106 coexist. 113 coexist.
107 114
108 *optimize* specifies the optimization level for the compiler. It is passed t o 115 *optimize* specifies the optimization level for the compiler. It is passed t o
109 the built-in :func:`compile` function. 116 the built-in :func:`compile` function.
117
118 If *processes* is given, :mod:`concurrent.futures` will be used to fire up
eric.araujo 2014/03/12 06:48:47 Not sure if it’s useful to give the detail that co
119 a number of workers for processing the directory tree concurrently.
110 120
111 .. versionchanged:: 3.2 121 .. versionchanged:: 3.2
112 Added the *legacy* and *optimize* parameter. 122 Added the *legacy* and *optimize* parameter.
113 123
124 .. versionchanged:: 3.5
125 Added the *processes* parameter.
126
114 127
115 .. function:: compile_file(fullname, ddir=None, force=False, rx=None, quiet=Fals e, legacy=False, optimize=-1) 128 .. function:: compile_file(fullname, ddir=None, force=False, rx=None, quiet=Fals e, legacy=False, optimize=-1)
116 129
117 Compile the file with path *fullname*. 130 Compile the file with path *fullname*.
118 131
119 If *ddir* is given, it is prepended to the path to the file being compiled 132 If *ddir* is given, it is prepended to the path to the file being compiled
120 for use in compilation time tracebacks, and is also compiled in to the 133 for use in compilation time tracebacks, and is also compiled in to the
121 byte-code file, where it will be used in tracebacks and other messages in 134 byte-code file, where it will be used in tracebacks and other messages in
122 cases where the source file does not exist at the time the byte-code file is 135 cases where the source file does not exist at the time the byte-code file is
123 executed. 136 executed.
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 175
163 # Perform same compilation, excluding files in .svn directories. 176 # Perform same compilation, excluding files in .svn directories.
164 import re 177 import re
165 compileall.compile_dir('Lib/', rx=re.compile(r'[/\\][.]svn'), force=True) 178 compileall.compile_dir('Lib/', rx=re.compile(r'[/\\][.]svn'), force=True)
166 179
167 180
168 .. seealso:: 181 .. seealso::
169 182
170 Module :mod:`py_compile` 183 Module :mod:`py_compile`
171 Byte-compile a single source file. 184 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+