Calling C++ Modules in Python

Discussion in 'Python' started by Patrick, Mar 11, 2011.

  1. Patrick

    Patrick Guest

    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
     
    Patrick, Mar 11, 2011
    #1
    1. Advertising

  2. 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
     
    Sophie Sperner, Mar 11, 2011
    #2
    1. Advertising

  3. Patrick

    Patrick Guest

    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.

    On Mar 11, 4:32 pm, Sophie Sperner <> wrote:
    > 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
     
    Patrick, Mar 11, 2011
    #3
  4. Patrick

    Terry Reedy Guest

    On 3/11/2011 4:15 PM, Patrick wrote:
    > 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.

    --
    Terry Jan Reedy
     
    Terry Reedy, Mar 12, 2011
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Remy Cool
    Replies:
    1
    Views:
    446
    Remy Cool
    Aug 27, 2003
  2. Tobiah
    Replies:
    2
    Views:
    323
    Tobiah
    Sep 14, 2003
  3. David Bear

    calling perl modules from python

    David Bear, May 11, 2006, in forum: Python
    Replies:
    3
    Views:
    422
    Ravi Teja
    May 12, 2006
  4. Ben Weintraub

    Disabling modules using Modules/Setup

    Ben Weintraub, Sep 9, 2006, in forum: Python
    Replies:
    0
    Views:
    362
    Ben Weintraub
    Sep 9, 2006
  5. mannewalis
    Replies:
    1
    Views:
    929
    Graham Dumpleton
    Oct 17, 2007
Loading...

Share This Page