script::python::ffi_types::copr::compile

Function compile_script

source
pub fn compile_script(
    name: &str,
    deco_args: &DecoratorArgs,
    kwarg: &Option<String>,
    script: &str,
) -> Result<CodeObject>
Expand description

stripe the decorator(@xxxx) and type annotation(for type checker is done in rust function), add one line in the ast for call function with given parameter, and compiler into CodeObject

The rationale is that rustpython’s vm is not very efficient according to official benchmark, So we should avoid running too much Python Bytecode, hence in this function we delete @ decorator(instead of actually write a decorator in python) And add a function call in the end and also strip type annotation