[Numpy-discussion] Options for wrapping C and C++ code for use with Numeric
Chris Barker
Chris.Barker at noaa.gov
Thu Nov 3 12:08:55 EST 2005
Hi all,
I suddenly seem to have the need for working with a bunch of different
existing C and C++ code, so I'm looking for a way to make it easier. I
love NumPy, so I really want to use NumPy arrays My needs fall into
three categories:
1) Writing custom extension code from scratch:
In the past, I've done this by just using the NumPy API, but it seems
that I shouldn't have to do all that book keeping myself.
2) Wrapping existing libraries:
At the moment, I'd like to wrap Richard Shewchuk's triangle:
http://www.cs.cmu.edu/~quake/triangle.html
Which is straight C, as well as the Proj4 map projections library, also
C, and there may be others.
3) Wrapping in house code, C & C++, that is under development, but I
want to be able to use it from Python and C++, and also perhaps to write
tests for it in Python.
The options I'm looking at are:
Pyrex:
This seems like perhaps the easiest way to write extension code, but it
doesn't do any automatic wrapping.
Boost::Python:
This looks like a very nice way to write extension modules, and it even
appears to already include support for NumPy arrays (which ones? is that
support being maintained, and will it support SciPy.base?)
SWIG:
The has the major advantage of automatically wrapping code. I see this
as a particular strength for wrapping our in house code that is under
development. In theory, once I've written a bunch of type maps, i can
just re-run it whenever the code base changes.
For each of these, I'd love to hear what people's experiences have been,
and it would be great if anyone can point me to samples that are small
but non-trivial. Other options I should consider would be great too.
One more question: Should I use NumPy arrays to pass data back and forth
between Python and C, or should I use the new array object/protocol
instead? If so, has anyone developed examples, SWIG type maps, etc for this?
Thanks for any feedback,
-Chris
--
Christopher Barker, Ph.D.
Oceanographer
NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chris.Barker at noaa.gov
More information about the NumPy-Discussion
mailing list