for running code are generally required to have __builtins__ link to the built-in scope searched last for name lookupsset with code of this formpydict_setitemstring(pdict"__builtins__"pyeval_getbuiltins())this is esotericand it is normally handled by python internally for modules and builtins like the exec function for raw dictionaries used as namespacesthoughwe are responsible for setting the link manually if we expect to reference built-in names this still holds true in python precompiling strings to bytecode finallywhen you call python function objects from cyou are actually running the already compiled bytecode associated with the object ( function body)normally created when the enclosing module is imported when running stringspython must compile the string before running it because compilation is slow processthis can be substantial overhead if you run code string more than once insteadprecompile the string to bytecode object to be run laterusing the api calls illustrated in example - py_compilestring compiles string of code and returns bytecode object pyeval_evalcode runs compiled bytecode object the first of these takes the mode flag that is normally passed to pyrun_stringas well as second string argument that is used only in error messages the second takes two namespace dictionaries these two api calls are used in example - to compile and execute three strings of python code in turn example - pp \integrate\embed\basics\embed-bytecode /precompile code strings to bytecode objects *#include #include #include main(int ichar *cvalpyobject *pcode *pcode *pcode *presult*pdictchar *codestr *codestr *codestr printf("embed-bytecode\ ")py_initialize()codestr "import usermod\nprint(usermod message)"codestr "usermod transform(usermod message)"codestr "print('% :% (xx * )end=')" python/ integration /statements */expression */use input *