[Numpy-discussion] swig numpy2carray converters
Georg Holzmann
grh@mur...
Tue Nov 20 02:12:08 CST 2007
Hallo!
> How is this better/different than numpy.i in:
>
> numpy/doc/swig/numpy.i
The problem I had with numpy.i:
- it copies the arrays on output (Argout Arrays) which was not possible
for my algorithms (I have some very big matrices)
- it is not possible to 2D or 3D Argout Arrays (why?), in the docs:
---8<---
Note that we support DATA_TYPE* argout typemaps in 1D, but not 2D or 3D.
This because of a quirk
with the SWIG typemap syntax and cannot be avoided. Note that for these
types of 1D typemaps, the
python function will take a single argument representing DIM1.
---8<---
- I also needed an output of fortran style arrays
>> (I also included an example for an interface to
>> fortran style arrays).
>
> That, it doesn't have.
It has ;) ... look in numpy2carray.i, FARRAY2_OUT (line 175).
But yes, sorry, I did no example in example.cpp ...
> Just trying to keep too much effort from being duplicated....
Yes, of course. Actually I did not want to write that code ;).
I was (and still am) a numpy beginner and needed to use my library in it
- so all the people said it's so easy to do ...
Then I tried boost.python and swig and I spent a lot of time trying to
get that work, writing on maiiling lists ... - I did not think before
that it would be that hard - and I don't understand why nobody else
needed that before.
Maybe this could also be integrated in numpy/doc/swig/numpy.i - but
however, this is so much code and I didn't really understand how I
should change that to my needs and also asked on the mailinglists ...
OTOH the umfpack.i bindings in scipy where quite nice, much easier to
read, but of course tuned to their task ...
Therefore I made these wrappers, which should be easier to understand
for beginners, how to write there own wrappers and tune them to their needs.
LG
Georg
More information about the Numpy-discussion
mailing list