Python:C++ interfacing. Tool selection recommendations

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • adsheehan@eircom.net

    #1

    Python:C++ interfacing. Tool selection recommendations

    Hi,

    I am embedding Python with a C++ app and need to provide the Python
    world with access to objects & data with the C++ world.

    I am aware or SWIG, BOOST, SIP. Are there more?

    I welcome comments of the pros/cons of each and recommendations on when
    it appropriate to select one over the others.

    Thanks in advance.

    Alan

  • Diez B. Roggisch

    #2
    Re: Python:C++ interfacing. Tool selection recommendations

    adsheehan@eirco m.net wrote:[color=blue]
    > Hi,
    >
    > I am embedding Python with a C++ app and need to provide the Python
    > world with access to objects & data with the C++ world.
    >
    > I am aware or SWIG, BOOST, SIP. Are there more?
    >
    > I welcome comments of the pros/cons of each and recommendations on when
    > it appropriate to select one over the others.[/color]

    SWIG is rather primitive - to get OO-Style Objects, you need to create
    python wrappers yourself, that have an object-reference and call all
    generated wrapper functions with that as fisrt argument. SIP is way more
    elegant in thast respect. I never tried boost.

    Diez

    Comment

    • Neal Becker

      #3
      Re: Python:C++ interfacing. Tool selection recommendations

      adsheehan@eirco m.net wrote:
      [color=blue]
      > Hi,
      >
      > I am embedding Python with a C++ app and need to provide the Python
      > world with access to objects & data with the C++ world.
      >
      > I am aware or SWIG, BOOST, SIP. Are there more?
      >
      > I welcome comments of the pros/cons of each and recommendations on when
      > it appropriate to select one over the others.
      >[/color]

      boost::python is alien technology. It is amazingly powerful. Once you
      learn how to use it it's wonderful, but unless you are comfortable with
      modern c++ you may find the learning curve steep.

      Comment

      • float_dublin

        #4
        Re: Python:C++ interfacing. Tool selection recommendations

        Neal Becker wrote:[color=blue]
        > adsheehan@eirco m.net wrote:
        >
        >[color=green]
        >>Hi,
        >>
        >>I am embedding Python with a C++ app and need to provide the Python
        >>world with access to objects & data with the C++ world.
        >>
        >>I am aware or SWIG, BOOST, SIP. Are there more?
        >>
        >>I welcome comments of the pros/cons of each and recommendations on when
        >>it appropriate to select one over the others.
        >>[/color]
        >
        >
        > boost::python is alien technology. It is amazingly powerful. Once you
        > learn how to use it it's wonderful, but unless you are comfortable with
        > modern c++ you may find the learning curve steep.
        >[/color]
        Note: there is excelent Pyste python prog inside that autogenerates
        boost::python code for you from special describtion files (where you can
        actualy write AllFromHeader(" xxx.h")) and your header files.
        Boost::python is the best solution, but the compile time of wrappers.

        --
        float_dublin

        Comment

        • Jorgen Grahn

          #5
          Re: Python:C++ interfacing. Tool selection recommendations

          On Fri, 16 Sep 2005 12:04:40 -0400, Neal Becker <ndbecker2@gmai l.com> wrote:[color=blue]
          > adsheehan@eirco m.net wrote:
          >[color=green]
          >> Hi,
          >>
          >> I am embedding Python with a C++ app and need to provide the Python
          >> world with access to objects & data with the C++ world.
          >>
          >> I am aware or SWIG, BOOST, SIP. Are there more?
          >>
          >> I welcome comments of the pros/cons of each and recommendations on when
          >> it appropriate to select one over the others.[/color]
          >
          > boost::python is alien technology. It is amazingly powerful. Once you
          > learn how to use it it's wonderful, but unless you are comfortable with
          > modern c++ you may find the learning curve steep.[/color]

          That last part sounds like a good thing -- if the OP dealing with C++ code,
          he should be, or become, comfortable with modern C++.

          In my other life as a C++ programmer, I'm thoroughly fed up with people who
          keep writing 1980s-style C++ ...

          (I wonder, by the way, if it's a good idea to provide a very rich interface
          between an application and embedded Python. I have no experience in the
          area, but intuition tells me that simplicity and minimalism is important.
          How well has this worked out in past projects?)

          /Jorgen

          --
          // Jorgen Grahn <jgrahn@ Ph'nglui mglw'nafh Cthulhu
          \X/ algonet.se> R'lyeh wgah'nagl fhtagn!

          Comment

          • Diez B. Roggisch

            #6
            Re: Python:C++ interfacing. Tool selection recommendations

            > (I wonder, by the way, if it's a good idea to provide a very rich interface[color=blue]
            > between an application and embedded Python. I have no experience in the
            > area, but intuition tells me that simplicity and minimalism is important.
            > How well has this worked out in past projects?)[/color]

            Check out SIP and the PyQt/PyKDE binding for an example of a
            full-fledged C++ library wrapped. But I still think your point is valid :)


            Diez

            Comment

            • Mike Meyer

              #7
              Re: Python:C++ interfacing. Tool selection recommendations

              > (I wonder, by the way, if it's a good idea to provide a very rich interface[color=blue]
              > between an application and embedded Python. I have no experience in the
              > area, but intuition tells me that simplicity and minimalism is important.[/color]

              So long as you distinguish between minimalist and the bare minimum. My
              experience with using and building systems with embedded interpreters
              shows that you can never tell what a user will want to do. If you
              provide some functionality that can't be invoked from the embedded
              python, you can guarantee that some user somewhere will want that
              functionality.

              So your "minimal" interface should include the ability to do anything
              that the application user can do from whatever interface you
              provide. That may include functionality that the environment normally
              provides for manipulating your application - unless the environment
              provides tools for scripting that functionality.
              [color=blue]
              > How well has this worked out in past projects?)[/color]

              Applications that fail to provide complete functionality have worked
              out poorly, usually leaving me frustrated. The most recent example is
              Apple's Terminal application in OS X. I want to open a new window,
              make it use a font other than the default font, resize the window,
              then launch an application in that window passing it an argument from
              the command line. This can't be automated because Apple left part of
              the functionality out of their scripting interface. As a result, I'm
              reduced to using xterm - which has problems of it's own.

              <mike
              --
              Mike Meyer <mwm@mired.or g> http://www.mired.org/home/mwm/
              Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.

              Comment

              • adsheehan@eircom.net

                #8
                Re: Python:C++ interfacing. Tool selection recommendations

                Thanks to all for your postings.

                Seems like a spread of opinions here.
                I guess SWIG, SIP & BOOST are all valid options which I need to vaidate
                in turn....

                Alan

                Comment

                Working...