Neal said:
Helmut Jarausch wrote:
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