Van at Lindbergs.org
Sun Mar 24 17:19:23 CET 2002
I'm trying to embed python in a C program. I already have the
libraries, header files, linker options, etc worked out -- I can compile
and run a program that embeds a python module both with the python/C
api and with Mark Lutz's ppembed API. I can also move values between
python and C.
The problem is that I'm not sure how to maintain state in the python
class I'm using.
Ideally, I would only like to expose four functions to C:
(called once) setup(int type)
This would initialize python and a python class with the passed-in value
(Used internally by the python class).
This python class would also import other modules (both builtin and
custom; the custom ones would be pure python)
(called repeatedly) update(int x, int y, int z)
This would update state within the python class instance
(called repeatedly) getPt()
This would fetch some variables from the python class instance, put them
into a struct, and return the struct
(called once) cleanup()
My problem is the following:
How do I keep the class instance around so that I can maintain state?
The getPt function would return variables that in part are functions of
previous inputs, not just the current input.
Please help! It would be greatly appreciated.
More information about the Python-list