Python C++

Discussion in 'Python' started by Francois Fernandes, Jul 16, 2004.

  1. Hi!

    Is it possible to easyly integrate c++ classes in python?

    I don't want to use boost c++.

    Does anyone know how to start or where to find documentation for this?

    thx
    Francois Fernandes, Jul 16, 2004
    #1
    1. Advertising

  2. On Friday 16 July 2004 10:08 pm, Francois Fernandes wrote:
    > Hi!
    >
    > Is it possible to easyly integrate c++ classes in python?
    >
    > I don't want to use boost c++.
    >
    > Does anyone know how to start or where to find documentation for this?


    http://www.river-bank.demon.co.uk/docs/sip/sipref.html

    Phil
    Phil Thompson, Jul 16, 2004
    #2
    1. Advertising

  3. =?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=, Jul 16, 2004
    #3
  4. Francois Fernandes wrote:

    > Hi!
    >
    > Is it possible to easyly integrate c++ classes in python?
    >
    > I don't want to use boost c++.
    >
    > Does anyone know how to start or where to find documentation for this?
    >
    > thx


    Your choices are:
    - SWIG http://www.swig.org/
    - SIP (Phil Thompson has already provided the URL)
    - Boost.Python (you already know about this it appears)

    --
    Mike
    Mike Thompson, Jul 17, 2004
    #4
  5. Francois Fernandes

    John J. Lee Guest

    Phil Thompson <> writes:

    > On Friday 16 July 2004 10:08 pm, Francois Fernandes wrote:
    > > Hi!
    > >
    > > Is it possible to easyly integrate c++ classes in python?
    > >
    > > I don't want to use boost c++.
    > >
    > > Does anyone know how to start or where to find documentation for this?

    >
    > http://www.river-bank.demon.co.uk/docs/sip/sipref.html


    Excellent -- looks like comprehensive documentation with enough of a
    tutorial element to smooth the path a bit. Boost Python has some
    competition.

    (sip has been around for a long time, but until recently there were no
    docs to speak of.)

    SWIG used to be pretty poor for wrapping C++. Has it got better?


    John
    John J. Lee, Jul 17, 2004
    #5
  6. Francois Fernandes

    Humpdydum Guest

    > > > Is it possible to easyly integrate c++ classes in python?
    > > >

    > >
    > > http://www.river-bank.demon.co.uk/docs/sip/sipref.html

    >
    >
    > SWIG used to be pretty poor for wrapping C++. Has it got better?


    A couple of months ago when I looked at SWIG, it seemed to support almost
    every C++ feature (templates and all), but I ended up not needing it so I
    can't say how that translates in practice.

    One problem with Boost is that it is such a big library and you have to get
    the whole thing even if you just need a couple of "packages".

    Oliver
    Humpdydum, Jul 19, 2004
    #6
  7. Francois Fernandes wrote:
    > Hi!
    >
    > Is it possible to easyly integrate c++ classes in python?
    >
    > I don't want to use boost c++.
    >
    > Does anyone know how to start or where to find documentation for this?
    >


    I prefer PyCXX http://cxx.sourceforge.net


    --
    Helmut Jarausch

    Lehrstuhl fuer Numerische Mathematik
    RWTH - Aachen University
    D 52056 Aachen, Germany
    Helmut Jarausch, Jul 21, 2004
    #7
  8. Helmut Jarausch wrote:

    > Francois Fernandes wrote:
    >> Hi!
    >>
    >> Is it possible to easyly integrate c++ classes in python?
    >>
    >> I don't want to use boost c++.
    >>
    >> Does anyone know how to start or where to find documentation for this?
    >>

    >
    > I prefer PyCXX http://cxx.sourceforge.net
    >
    >


    Looks interesting. I want to expose lots of signal processing algorithms
    written in C++ to python. I want to use std::vector for containers,
    because they are fast. I need to create python types for
    std::vector<double> and std::vector<std::complex<double>> at minimum. The
    Python interface doesn't need to know much about these types, just be able
    to create vectors of a given size.

    Would PyCXX be a good choice for this? Are there any samples of code
    similar to this?
    Neal D. Becker, Jul 21, 2004
    #8
  9. Neal D. Becker wrote:
    > Helmut Jarausch wrote:
    >
    >
    >>Francois Fernandes wrote:
    >>
    >>>Hi!
    >>>
    >>>Is it possible to easyly integrate c++ classes in python?
    >>>
    >>>I don't want to use boost c++.
    >>>
    >>>Does anyone know how to start or where to find documentation for this?
    >>>

    >>
    >>I prefer PyCXX http://cxx.sourceforge.net
    >>
    >>

    >
    >
    > Looks interesting. I want to expose lots of signal processing algorithms
    > written in C++ to python. I want to use std::vector for containers,
    > because they are fast. I need to create python types for
    > std::vector<double> and std::vector<std::complex<double>> at minimum. The
    > Python interface doesn't need to know much about these types, just be able
    > to create vectors of a given size.
    >
    > Would PyCXX be a good choice for this? Are there any samples of code
    > similar to this?
    >


    I think, yes. PyCXX allows for use of the STL.
    For each type FOO in your module you provide a new_FOO which is called when you
    create an object. There you can call any C++ code including class constructors.
    PyCXX helps you in filling out these long structs needed for a new type.
    It helps with exception handling and reference counting.
    I am new to PyCXX myself, but it worked very soon. There is a rather general
    example in the Demo directory. I've just copied and modified the code and it
    worked like expected - GREAT! The documentation is not too long but suffucient
    and very readable. It does NOT (try to) wrap your C++ classes automatically like
    other tools. I prefer this (since I don't have hundreds of classes). One can
    easily fully understand what's going on and if something is missing (e.g. I think
    conversion of an unsigned int to a Python long int) one can easily add this
    feature using calls from the C-API himself.


    --
    Helmut Jarausch

    Lehrstuhl fuer Numerische Mathematik
    RWTH - Aachen University
    D 52056 Aachen, Germany
    Helmut Jarausch, Jul 23, 2004
    #9
  10. Neal D. Becker wrote:
    > Helmut Jarausch wrote:
    >
    >
    >>Francois Fernandes wrote:
    >>
    >>>Hi!
    >>>
    >>>Is it possible to easyly integrate c++ classes in python?
    >>>
    >>>I don't want to use boost c++.
    >>>
    >>>Does anyone know how to start or where to find documentation for this?
    >>>

    >>
    >>I prefer PyCXX http://cxx.sourceforge.net
    >>
    >>

    >
    >
    > Looks interesting. I want to expose lots of signal processing algorithms
    > written in C++ to python. I want to use std::vector for containers,
    > because they are fast. I need to create python types for
    > std::vector<double> and std::vector<std::complex<double>> at minimum. The
    > Python interface doesn't need to know much about these types, just be able
    > to create vectors of a given size.
    >
    > Would PyCXX be a good choice for this? Are there any samples of code
    > similar to this?
    >


    I think, yes. PyCXX allows for use of the STL.
    For each type FOO in your module you provide a new_FOO which is called when you
    create an object. There you can call any C++ code including class constructors.
    PyCXX helps you in filling out these long structs needed for a new type.
    It helps with exception handling and reference counting.
    I am new to PyCXX myself, but it worked very soon. There is a rather general
    example in the Demo directory. I've just copied and modified the code and it
    worked like expected - GREAT! The documentation is not too long but suffucient
    and very readable. It does NOT (try to) wrap your C++ classes automatically like
    other tools. I prefer this (since I don't have hundreds of classes). One can
    easily fully understand what's going on and if something is missing (e.g. I think
    conversion of an unsigned int to a Python long int) one can easily add this
    feature using calls from the C-API himself.


    --
    Helmut Jarausch

    Lehrstuhl fuer Numerische Mathematik
    RWTH - Aachen University
    D 52056 Aachen, Germany
    Helmut Jarausch, Jul 23, 2004
    #10
    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. Replies:
    0
    Views:
    740
  2. Paul Moore
    Replies:
    0
    Views:
    611
    Paul Moore
    Mar 1, 2008
  3. Martin v. Löwis
    Replies:
    0
    Views:
    650
    Martin v. Löwis
    Mar 1, 2008
  4. Senthil Kumaran
    Replies:
    0
    Views:
    571
    Senthil Kumaran
    Jan 17, 2011
  5. R. David Murray
    Replies:
    0
    Views:
    750
    R. David Murray
    Jan 17, 2011
Loading...

Share This Page