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
[Python-Dev] Embedded Python:: C/Python: Is Py_Finalize() necessary between embedded function calls?
| Tweet |
|
Search Discussions
-
Oleg Broytmann at Feb 25, 2007 at 2:48 pm ⇧
As far I understand you only need to call Py_Initialize() andOn Fri, Feb 23, 2007 at 04:24:19AM -0800, Sydney Pang wrote:
do I have to call Py_Finalize() at
the end of each Python embedded C function?
Py_Finalize() once per every embedded interpreter, not for an every
function.
Oleg.--
Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru
Programmers don't die, they just GOSUB without RETURN.
Related Discussions
Discussion Navigation
| view | thread | post |
Discussion Overview
| group | python-dev |
| categories | python |
| posted | Feb 23, '07 at 12:24p |
| active | Feb 25, '07 at 2:48p |
| posts | 2 |
| users | 2 |
| website | python.org |
