Extending C++ with Python scripting: "twin objects" or "proxy objects"?

jdetaeye johan.de.taeye at gmail.com
Tue Mar 18 03:51:58 EDT 2008


Hi,

I would like to use Python as a scripting language for a C++ framework
I am working on.

The most common approach for this seems to be a "twin objects": the
python and the C++ object have the same lifespan and are always linked
to each other.
My initial thinking was to use a "proxy approach" instead: the python
object is only a temporary proxy object with a pointer to the real C++
object. The C++ object would live much longer than the proxy.

Is the proxy approach a valid alternative?  I can't imagine it hasn't
been done before...
I am interested in hearing your experiences with it...

Currently I see the following + and -:
+ Easier for the C++ code (ie less changes, less coupling, no gc-
issues)
- Extending the framework through subclasses in Python is much harder
Anything else?

Regards,

Johan



More information about the Python-list mailing list