diff options
Diffstat (limited to 'Python/compile.c')
-rw-r--r-- | Python/compile.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/Python/compile.c b/Python/compile.c index 3260dba..4b2f70a 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -557,6 +557,24 @@ _PyAST_Compile(mod_ty mod, PyObject *filename, PyCompilerFlags *pflags, return co; } +int +_PyCompile_AstOptimize(mod_ty mod, PyObject *filename, PyCompilerFlags *cf, + int optimize, PyArena *arena) +{ + PyFutureFeatures future; + if (!_PyFuture_FromAST(mod, filename, &future)) { + return -1; + } + int flags = future.ff_features | cf->cf_flags; + if (optimize == -1) { + optimize = _Py_GetConfig()->optimization_level; + } + if (!_PyAST_Optimize(mod, arena, optimize, flags)) { + return -1; + } + return 0; +} + static void compiler_free(struct compiler *c) { |