Wrapper for Cosmo3D swig vs c++

bjorn bjorn at roguewave.com
Tue Feb 8 13:14:42 EST 2000

I haven't used CXX, so I can't give you any comparisons...  However, as
far as swig goes, it's only a very minor perfomance hit in converting the
arguments to and from Python objects.  Any routine that is too slow should
be relatively easy to translate to c/c++ and then swig.

It also seems like you're under the misconception that swig will take your
c++ header files and generate shadow classes directly.  Unfortunately this
is not true.  With some work (sometimes a lot of work) it can be possible
to get swig to parse a c++ header file, most of the time it is better to
just bite the bullet and write the interface file.  Areas to watch out for
are inline code, and overloads (I once wrote an elaborate scheme to get
overloading of the basic types from Python, which worked although it
wasn't very pythonesque).


Sunil Hadap wrote:

> Hello,
> I am set for creating wrappers for SGI's Cosmo3D 3d graphics API. The
> API is c++ one. As I count, there are around 100 classes, just to get
> idea of the volume. I have 2 options
> a) To use Swig - I learnt from the swig manual that it can help in
> creating the Python classes as in Cosmo3D at the cost of performance.
> I did not get the point. What I see is there is just a def statement
> in the shadow class which  links class member function to a swig
> generated wrapper function. I suppose def is a simple namespace alias
> which is not a major overhead. I hope I am not wrong. Is this
> something I should worry or just use swig with very minor performance
> overhead.
> b) Use c or better c++ (CXX) api. Am I getting into a big task
> considering 100 classes to wrap. Is it worth the performance I get. I
> have not even studied c/c++ API, hence could not visualize how it will
> improve the performance. After all swig will generate similar code
> except with different namespace entries, and then the shadow class.
> Thank you very much
> Sunil
> --
> "Live as if you would die tomorrow,
> learn as if you would live forever."
>                     --Mahatma Gandhi
> --
> http://www.python.org/mailman/listinfo/python-list

More information about the Python-list mailing list