Boost logo

Boost Users :

From: Chris Heald (yg-boost-users_at_[hidden])
Date: 2003-05-23 15:43:53


Hi all --

I'm working on an app that is going to be a C++ code engine which will be
heavily extended through a series of Python scripts (objects, really). My
desired requirements are as follows:

The environment is a C++ state machine, and each Python object should
persistantly maintain its own state. I assume I can instanciate a Python
object and maintain it in C++, then call it when necessary.

a) Embed the Python interpreter
b) Be able to pass values from the C++ state machine into the Python object
for internal use
c) Be able to call arbitrary Python functions from C++. I am currently doing
this with an event registration handler, where scripts will handle events
they want to handle, along with the function that should be called when the
event is fired.
d) Be able to update the C++ state machine with an interface exposed from
C++

I can do a and b easily enough - the examples make that clear. Where I'm
having trouble is with c and d - how do I give a Python app hooks into an
existing C++ state machine? I know I can write an extension easily enough,
but by my understanding, that will simply give the Python object access to a
series of functions, and not the objects contained in the state machine that
the interpreter is running under. I could use "pull" operations, wherein the
C++ app polls the objects for changed state in a loop and updates its sate
accordingly, but that seems that it wouldn't perform nearly so well as if
the Python scripts were able to update the C++ state machine themselves, so
I'm avoiding that route.

I had a co-worker suggest that I use Python as my primary execution
environment instead of C++. While this would admittedly make some things
easier, how much performance would I sacrifice with this route? I'm building
a 3D application, and it doesn't seem that Python would be well-suited to
such an application in terms of performance. There is potential for
literally tens of thousands of instances of these objects to exist in this
state machine, and I certainly don't want to hinder performance by moving
the primary execution into an interpreted environment rather than a compiled
environment.

Any words of wisdom? Or am I utterly failing to communicate clearly, as I
think I am? ;)

Thanks,

Chris


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net