diff options
author | Georg Brandl <georg@python.org> | 2010-12-04 10:26:46 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2010-12-04 10:26:46 (GMT) |
commit | 8334fd9285a8e9f0864b0453ae738fe3f6893b21 (patch) | |
tree | f9341847b4647cd85b6fcd4e5fbece5cd15e1883 /Doc/c-api/veryhigh.rst | |
parent | 427d3149ebe5c4495e69a04be5464e5b8b446c9e (diff) | |
download | cpython-8334fd9285a8e9f0864b0453ae738fe3f6893b21.zip cpython-8334fd9285a8e9f0864b0453ae738fe3f6893b21.tar.gz cpython-8334fd9285a8e9f0864b0453ae738fe3f6893b21.tar.bz2 |
Add an "optimize" parameter to compile() to control the optimization level, and provide an interface to it in py_compile, compileall and PyZipFile.
Diffstat (limited to 'Doc/c-api/veryhigh.rst')
-rw-r--r-- | Doc/c-api/veryhigh.rst | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/Doc/c-api/veryhigh.rst b/Doc/c-api/veryhigh.rst index 5b93325..3e41ec7 100644 --- a/Doc/c-api/veryhigh.rst +++ b/Doc/c-api/veryhigh.rst @@ -230,6 +230,12 @@ the same library that the Python runtime is using. .. c:function:: PyObject* Py_CompileStringFlags(const char *str, const char *filename, int start, PyCompilerFlags *flags) + This is a simplified interface to :c:func:`Py_CompileStringExFlags` below, with + *optimize* set to ``-1``. + + +.. c:function:: PyObject* Py_CompileStringExFlags(const char *str, const char *filename, int start, PyCompilerFlags *flags, int optimize) + Parse and compile the Python source code in *str*, returning the resulting code object. The start token is given by *start*; this can be used to constrain the code which can be compiled and should be :const:`Py_eval_input`, @@ -238,6 +244,14 @@ the same library that the Python runtime is using. :exc:`SyntaxError` exception messages. This returns *NULL* if the code cannot be parsed or compiled. + The integer *optimize* specifies the optimization level of the compiler; a + value of ``-1`` selects the optimization level of the interpreter as given by + :option:`-O` options. Explicit levels are ``0`` (no optimization; + ``__debug__`` is true), ``1`` (asserts are removed, ``__debug__`` is false) + or ``2`` (docstrings are removed too). + + .. versionadded:: 3.2 + .. c:function:: PyObject* PyEval_EvalCode(PyObject *co, PyObject *globals, PyObject *locals) |