blob: ebbc9b907b81308671d522e0104379a8681043dc [file] [log] [blame]
Fred Drake38e5d272000-04-03 20:13:55 +00001\section{\module{py_compile} ---
2 Compile Python source files}
3
Fred Drake4756bb31998-08-11 15:46:25 +00004% Documentation based on module docstrings, by Fred L. Drake, Jr.
5% <fdrake@acm.org>
6
Fred Drake4756bb31998-08-11 15:46:25 +00007\declaremodule[pycompile]{standard}{py_compile}
8
9\modulesynopsis{Compile Python source files to byte-code files.}
10
11
12\indexii{file}{byte-code}
13The \module{py_compile} module provides a single function to generate
14a byte-code file from a source file.
15
16Though not often needed, this function can be useful when installing
17modules for shared use, especially if some of the users may not have
18permission to write the byte-code cache files in the directory
19containing the source code.
20
21
22\begin{funcdesc}{compile}{file\optional{, cfile\optional{, dfile}}}
23 Compile a source file to byte-code and write out the byte-code cache
24 file. The source code is loaded from the file name \var{file}. The
25 byte-code is written to \var{cfile}, which defaults to \var{file}
26 \code{+} \code{'c'} (\code{'o'} if optimization is enabled in the
27 current interpreter). If \var{dfile} is specified, it is used as
28 the name of the source file in error messages instead of \var{file}.
29\end{funcdesc}
30
31
32\begin{seealso}
33 \seemodule{compileall}{Utilities to compile all Python source files
34 in a directory tree.}
35\end{seealso}