Embedding/Extending Python in/with C++: non-static members?

dmoore damienlmoore at gmail.com
Tue Jul 17 12:24:49 EDT 2007


(I thought I'd follow up on this post so as not to send unsuspecting
readers down a hopeless path)

duh!

I've obviously spent too much time with dynamic languages. The problem
with what I'm trying to do is obvious: In C++ you simply can't pass
pointers to call a particular instance of a C++ class method so there
is no way to initialize the PyMethodDef with class methods instances.
In other words, there is no callback mechanism built into the language
and you are stuck with template based approaches, which obviously
don't mesh very well with the Python/C API (without SWIG,
Boost::Python etc).

So to get a python interpreter instance to communicate with pre-
existing dynamically allocated C++ objects, it looks like I need to
implement some kind of lookup table approach. The static nature of the
Python/C API is just too cumbersome for use with multiple interpreters
and making me thing it might be better to embed just a sinlge
interpreter inside my app and use multi-process communication with
either pipes or sockets for the extra interpreters...




More information about the Python-list mailing list