summaryrefslogtreecommitdiffstats
path: root/Python/pythonrun.c
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2010-12-04 10:26:46 (GMT)
committerGeorg Brandl <georg@python.org>2010-12-04 10:26:46 (GMT)
commit8334fd9285a8e9f0864b0453ae738fe3f6893b21 (patch)
treef9341847b4647cd85b6fcd4e5fbece5cd15e1883 /Python/pythonrun.c
parent427d3149ebe5c4495e69a04be5464e5b8b446c9e (diff)
downloadcpython-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 'Python/pythonrun.c')
-rw-r--r--Python/pythonrun.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/Python/pythonrun.c b/Python/pythonrun.c
index 3f6385d..f7335a2 100644
--- a/Python/pythonrun.c
+++ b/Python/pythonrun.c
@@ -1793,8 +1793,8 @@ run_pyc_file(FILE *fp, const char *filename, PyObject *globals,
}
PyObject *
-Py_CompileStringFlags(const char *str, const char *filename, int start,
- PyCompilerFlags *flags)
+Py_CompileStringExFlags(const char *str, const char *filename, int start,
+ PyCompilerFlags *flags, int optimize)
{
PyCodeObject *co;
mod_ty mod;
@@ -1812,7 +1812,7 @@ Py_CompileStringFlags(const char *str, const char *filename, int start,
PyArena_Free(arena);
return result;
}
- co = PyAST_Compile(mod, filename, flags, arena);
+ co = PyAST_CompileEx(mod, filename, flags, optimize, arena);
PyArena_Free(arena);
return (PyObject *)co;
}
@@ -2450,7 +2450,15 @@ PyRun_SimpleString(const char *s)
PyAPI_FUNC(PyObject *)
Py_CompileString(const char *str, const char *p, int s)
{
- return Py_CompileStringFlags(str, p, s, NULL);
+ return Py_CompileStringExFlags(str, p, s, NULL, -1);
+}
+
+#undef Py_CompileStringFlags
+PyAPI_FUNC(PyObject *)
+Py_CompileStringFlags(const char *str, const char *p, int s,
+ PyCompilerFlags *flags)
+{
+ return Py_CompileStringExFlags(str, p, s, flags, -1);
}
#undef PyRun_InteractiveOne