By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,235 Members | 1,057 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,235 IT Pros & Developers. It's quick & easy.

Python:C++ interfacing. Tool selection recommendations

P: n/a
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

Sep 16 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
ad*******@eircom.net wrote:
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
Sep 16 '05 #2

P: n/a
ad*******@eircom.net wrote:
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.

Sep 16 '05 #3

P: n/a
Neal Becker wrote:
ad*******@eircom.net wrote:

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.

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.

--
float_dublin
Sep 16 '05 #4

P: n/a
On Fri, 16 Sep 2005 12:04:40 -0400, Neal Becker <nd*******@gmail.com> wrote:
ad*******@eircom.net wrote:
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.


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

--
// Jorgen Grahn <jgrahn@ Ph'nglui mglw'nafh Cthulhu
\X/ algonet.se> R'lyeh wgah'nagl fhtagn!
Sep 17 '05 #5

P: n/a
> (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
Sep 18 '05 #6

P: n/a
> (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
--
Mike Meyer <mw*@mired.org> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
Sep 18 '05 #7

P: n/a
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

Sep 19 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.