Python:C++ interfacing. Tool selection recommendations

A

adsheehan

Hi,

I am embedding Python with a C++ app and need to provide the Python
world with access to objects & data with the C++ world.

I am aware or SWIG, BOOST, SIP. Are there more?

I welcome comments of the pros/cons of each and recommendations on when
it appropriate to select one over the others.

Thanks in advance.

Alan
 
D

Diez B. Roggisch

Hi,

I am embedding Python with a C++ app and need to provide the Python
world with access to objects & data with the C++ world.

I am aware or SWIG, BOOST, SIP. Are there more?

I welcome comments of the pros/cons of each and recommendations on when
it appropriate to select one over the others.

SWIG is rather primitive - to get OO-Style Objects, you need to create
python wrappers yourself, that have an object-reference and call all
generated wrapper functions with that as fisrt argument. SIP is way more
elegant in thast respect. I never tried boost.

Diez
 
N

Neal Becker

Hi,

I am embedding Python with a C++ app and need to provide the Python
world with access to objects & data with the C++ world.

I am aware or SWIG, BOOST, SIP. Are there more?

I welcome comments of the pros/cons of each and recommendations on when
it appropriate to select one over the others.

boost::python is alien technology. It is amazingly powerful. Once you
learn how to use it it's wonderful, but unless you are comfortable with
modern c++ you may find the learning curve steep.
 
F

float_dublin

Neal said:
boost::python is alien technology. It is amazingly powerful. Once you
learn how to use it it's wonderful, but unless you are comfortable with
modern c++ you may find the learning curve steep.
Note: there is excelent Pyste python prog inside that autogenerates
boost::python code for you from special describtion files (where you can
actualy write AllFromHeader("xxx.h")) and your header files.
Boost::python is the best solution, but the compile time of wrappers.
 
J

Jorgen Grahn

boost::python is alien technology. It is amazingly powerful. Once you
learn how to use it it's wonderful, but unless you are comfortable with
modern c++ you may find the learning curve steep.

That last part sounds like a good thing -- if the OP dealing with C++ code,
he should be, or become, comfortable with modern C++.

In my other life as a C++ programmer, I'm thoroughly fed up with people who
keep writing 1980s-style C++ ...

(I wonder, by the way, if it's a good idea to provide a very rich interface
between an application and embedded Python. I have no experience in the
area, but intuition tells me that simplicity and minimalism is important.
How well has this worked out in past projects?)

/Jorgen
 
D

Diez B. Roggisch

(I wonder, by the way, if it's a good idea to provide a very rich interface
between an application and embedded Python. I have no experience in the
area, but intuition tells me that simplicity and minimalism is important.
How well has this worked out in past projects?)

Check out SIP and the PyQt/PyKDE binding for an example of a
full-fledged C++ library wrapped. But I still think your point is valid :)


Diez
 
M

Mike Meyer

(I wonder, by the way, if it's a good idea to provide a very rich interface
between an application and embedded Python. I have no experience in the
area, but intuition tells me that simplicity and minimalism is important.

So long as you distinguish between minimalist and the bare minimum. My
experience with using and building systems with embedded interpreters
shows that you can never tell what a user will want to do. If you
provide some functionality that can't be invoked from the embedded
python, you can guarantee that some user somewhere will want that
functionality.

So your "minimal" interface should include the ability to do anything
that the application user can do from whatever interface you
provide. That may include functionality that the environment normally
provides for manipulating your application - unless the environment
provides tools for scripting that functionality.
How well has this worked out in past projects?)

Applications that fail to provide complete functionality have worked
out poorly, usually leaving me frustrated. The most recent example is
Apple's Terminal application in OS X. I want to open a new window,
make it use a font other than the default font, resize the window,
then launch an application in that window passing it an argument from
the command line. This can't be automated because Apple left part of
the functionality out of their scripting interface. As a result, I'm
reduced to using xterm - which has problems of it's own.

<mike
 
A

adsheehan

Thanks to all for your postings.

Seems like a spread of opinions here.
I guess SWIG, SIP & BOOST are all valid options which I need to vaidate
in turn....

Alan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top