Due to refactoring/reworking on a controller I've had to embed a Python Interpreter inside a C application.  I can now call python functions and pass/get Objects into Python fine.
The python code is a controller for a robot (currently simulated),  this now needs make use of some C code for comparisons I'm making.
Previously the Python code created objects, read sensors, ran control code and wrote the outputs to motors.  All of this except the control code now needs to be done in C.  The problem I have is that Objects which are created in an init function (in python) which, when I come to run the control code no longer exist.
What is the best way to solve this?  My idea was to return the controllers from the init function and store references to them in the C, passing the reference to the controller each time it is called.
Thanks for any help.
This may not be the answer you want, but there are ways of working with C and Python other than embedding an interpreter inside a C application.
Namely, why don't you do the opposite? Create C libraries for Python? You can control the general flow of your application in Python, which is much more comfortable, and call C code whenever you see fit.
Again, I'm not really addressing your actual question, so feel free to ignore me.
Maintaining a Python Object when embedding in C