SWIG and Python in use?

Wolfgang wl at flexis.de
Tue Jul 8 04:58:21 EDT 2003


Hi,

Alan Sheehan wrote:

> I am considering scripting a large C++ application.
> 
> In particular I am interested in test driving and end-user scripting
> the "application layer" in Python and giving it access to a large
> collection of C++ objects and their methods.
> 
> I note that SWIG is a mature tool and refers to supporting Python
> v1.x.
> 
> Has/Does anyone use SWIG to bind with Python 2.x ?. 
> 
> Does it still work?
> Any pitfalls, caveats ?

I've used swig a little bit. It's very good to generate interfaces for
C librarys. It can build interfaces for a lot of languages not only
python.

To interface C++ there are some problems. Simple C++ clases are easy
to interface but if us use virtual methods, templates an so on that
possible with swig but you have to write a lot of wrapper code.
Not an easy task.

To interface the app to python 2.2 and above, consider to use
Boost.python: http://www.boost.org/libs/python/doc/index.html

Today I use Boost.python for my new projects. It's easy
to interface C++ librarys and all C++ stuff.
Less code to write and for me it's easier.
(I don't know the Python C Api in detail, with boost.python
I wrote a C++ interface for a database within 3 days)


bye by Wolfgang





More information about the Python-list mailing list