Calling C++ Modules in Python

P

Patrick

Hi,

I saw in the Beginner document that "•Is easily extended by adding new
modules implemented in a compiled language such as C or C++. ".

While to my investigation, it seems not that easy or did I miss
something?

boost python (C++ libraries need to be re-compiled with written
wrappers again?).
SWIG (It works by taking the declarations found in C/C++ header and
using them to generate the wrapper code that scripting languages need
to access the underlying C/C++ code).

Thanks
-Patrick
 
S

Sophie Sperner

Hi Patrick,


I'm using SWIG in my project. C++ code is wrapped and can be used in
python as custom module.
You should create a swig module.i file to describe headers upon which
that module will be built.

You should be certain about what you are going to use - boost library,
swig or something else, try it and if any problems post here :)


Yours,
Sophie
 
P

Patrick

Thanks Sophie for the information. Yes, right now I am not certain
about what I am going to use for I was hoping for a "non-intrusive"
way to expose existing C++ libraries to python. However, both
solutions (BOOST, SWIG) listed here require the recompilation of
libraries?! It is ok for small applications but will be hard for big
software from big companies. The reason is that even companies are
willing to rebuild their own libraries with those wrappers or
decorations added(though needs approves from all sorts of
departments :)), they can't force their 3rd-party developers/users.
Correct me if I am wrong.

Cheers,
-Patrick.
 
T

Terry Reedy

Hi,

I saw in the Beginner document that "•Is easily extended by adding new
modules implemented in a compiled language such as C or C++. ".

While to my investigation, it seems not that easy or did I miss
something?

boost python (C++ libraries need to be re-compiled with written
wrappers again?).
SWIG (It works by taking the declarations found in C/C++ header and
using them to generate the wrapper code that scripting languages need
to access the underlying C/C++ code).

cytpes does not require recompilation. Not as fast either. But good
enough for many purposes.
 

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

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,050
Latest member
AngelS122

Latest Threads

Top