Options for interfacing python to C/C++ libraries include the following. This is not a complete list and I don't have much information on the items, it's just intended to start a discussion.
- SWIG: powerful, but somewhat hard to use. It is under active development.
- SIP: developed to support PyQt. One older published test showed it much faster than SWIG or Boost Python. Actively maintained.
- Boost Python: designed for interfacing to C++ libraries. Reportedly results in slow compilation and fat libraries due to instantiating all possible templates. Does not appear to be under active development.
- CXX: a set of classes to help create extensions of Python in the C++ language. I don't know anything further.
- ctypes: built into python and very easy to use. However it only interfaces to C, not C++ so will be of limited use for LSST.
- Pyrex: reportedly very easy to use, but only wraps C, not C++
Discussion:
- Here is an interesting comparison (pdf) of SWIG, Boost Python, SIP and Babel by Ola Skavhaug, et. al. from 2004. It gives a sense of relative complexity and performance. At that time SIP was significantly faster than SWIG or Boost Python.
- In a recent discussion of this topic on a scipy mailing list, two people felt Boost Python was elegant but not a good idea in practice and one of those recommended SWIG instead. No alternatives were mentioned except a brief mention of PyRoot as a source of ideas.
Unless someone comes up with more information, I suggest we stick with SWIG and also allow ctypes for interfacing to 3rd party C libraries.
As an aside weave package may also be of interest in a few cases to avoid the need for an external C++ library in the first place. It allows one to include short bits of C++ code directly in python.
