8.2. Run Bytecode Directly

    By avoiding the use of to execute python scripts and running the bytecode directly, the compiler will automatically optimize the Python parsed code and reduce the code size footprint.

    The precompiler rust-msc-latest-win10.exe integrates a bytecode generator that compiles main.py and the .py files imported by main.py (including indirect import) to bytecode when precompiling, and the generated bytecode files are in the pikascript-api folder.

    At the same time, all .py.o files are automatically packaged into a library file , which contains all bytecode files.

    To facilitate the loading of the library files in mcu when compiling the firmware, the precompiler also automatically converts the library files to C byte array files pikascript-api/__asset_pikaModules_py_a.c.

    Library files can be imported using the obj_linkLibrary() API, refer to the automatically generated pikaScriptInit()

    It is also possible to run a module directly as a script, e.g.

    Read data from a single bytecode file and then use the pikaVM_runByteCode() API to just run the single bytecode directly, see the usage of starting from bytecode in g030.