Embedding python: Running precompiled code.

Lucio Torre lucio at movilogic.com
Fri Nov 23 23:04:52 CET 2001


Hello,

I have embedded python in my aplication and i am running code using:

 po = PyRun_String("print 'hello'", Py_file_input, d, d);

But i want to have the code precompiled so it can run faster. so i would 
like to do:

PyObject* Py_CompileString(char *str, char *filename,
                                               int start)
Return value: New reference.
Parse and compile the Python source code in str, returning the   
resulting code object.  The start token is given by start;   this can be 
used to constrain the code which can be compiled and should  be 
Py_eval_input, Py_file_input, or   Py_single_input.  The filename 
specified by  filename is used to construct the code object and may 
appear  in tracebacks or SyntaxError exception messages.  This  returns 
NULL if the code cannot be parsed or compiled.

But how do i run the new python object?

any help aprettiated,

Lucio






More information about the Python-list mailing list