#64 Generate C/C++ interface to Python Module

closed
nobody
None
5
2009-03-26
2009-03-18
Nick
No

It would be nice if swig could generate a C/C++ .h and .cc file for a Python module. This would allow a simple way to embed Python in C/C++ applications.

I currently embed matplotlib in my C++ project but I thought there has got to be a better way to do it.

Discussion

  • William Fulton

    William Fulton - 2009-03-21

    Please explain. What is the input and output and what would go into the .h and .cc file?

     
  • Olly Betts

    Olly Betts - 2009-03-21

    Unless I've misunderstood, the suggestion is to effectively do the reverse of what SWIG does and allow calling Python from C/C++. Probably a bit like what GIWS does for C/C++ to Java, but I've never tried to use it:

    http://www.scilab.org/giws/

    Python already provides the ability to embed an interpreter:

    http://www.python.org/doc/2.5.2/ext/embedding.html

    But I guess you can't just call foo(1, "hello", 4.7) in C++ to execute foo(1, "hello", 4.7) in Python - you'd need to write such a wrapper by hand, and it's not inconceivable that SWIG could automate generation of such wrappers.

    Personally, I think this is probably too much feature creep, particularly since we're already short of developers to achieve the existing goals.

     
  • nitro

    nitro - 2009-03-21

    SWIG's directors allow you to call python code from C++ code in a certain way. However, the SWIG mailing lists are a better place to discuss these things than this issue tracker I think.

     
  • Olly Betts

    Olly Betts - 2009-03-26

    Agreed - closing this ticket.

     
  • Olly Betts

    Olly Betts - 2009-03-26
    • status: open --> closed
     

Log in to post a comment.