[Python-Dev] Embedded Python:: C/Python: Is Py_Finalize() necessary between embedded function calls?
Sydney Pang
sydney.pang at gmail.com
Fri Feb 23 13:24:19 CET 2007
Hi, I am developing an application where I have Python embedded in C
functions using the C/Python API to execute commands. My question stems
from my need to preserve a PyObject to pass between these Python
embedded C functions. My question is: do I have to call Py_Finalize() at
the end of each Python embedded C function?
The abstract structure of my code looks like this:
PyObject *po;
main() {
po = py_function_1();
// some C code in the middle here...
po = py_function_2(po);
// some more C code here...
}
In my implementation of py_function_1 and py_function_2 do I have to
call Py_Initialize() and Py_Finalize at the beginning and end of each of
the two functions? Or can I just call Py_Initialize at the beginning of
py_function_1 and then call Py_Finalize() at the end of py_function_2?
Thank You.
SP
More information about the Python-Dev
mailing list