[SciPy-user] FYI: C++ Extensions for Python
david at dwavesys.com
Mon Nov 1 18:03:58 CST 2004
Bob Ippolito wrote:
> On Nov 1, 2004, at 17:51, David Grant wrote:
>> Just thought I'd share my experiences concerning looking for a way to
>> make python interfaces for C++ code (see my previous thread about this):
>> pycxx - Looks like it requires one to modify all the C++ source,
>> adding PyObject pointers everywhere. I stayed away from this. I
>> don't want to modify the code if I have to (why should I have to?
>> the reason I'm making an interface is so that I can use the C++ code,
>> and not touch it, thus avoiding creating bugs in the C++ code. If I
>> WANTED to touch the C++ code I'd just re-write in python).
>> boost.python - Horrible documentation and horrible setup. Nothing
>> good to say about this. I spent more time on this than any other
>> method and made the least progress.
>> weave - was going to write a python routine which had some small
>> piece weave code. The weave code would be talking to a C++ library
>> or compiled python extension or something. I was able to make a C++
>> library containing all my C++ code but then abandoned it after that,
>> to see if there were simpler methods
>> python.org method - http://docs.python.org/ext/simpleExample.html -
>> Similar to pycxx it involved altering the code
>> swig - at first it seemed like a lot of work to copy everything from
>> the .h files into the .i file. But then I realized you can just use
>> %include and it will use that stuff for swig. Simple examples are
>> given in the docs for both C and C++ which work well. I like how it
>> just generates an extra .c wrapper file which is then compiled to a
>> .o file and linked together will all the other .o files and libraries
>> (like -llapack) into a python extension, very simply. Extend any
>> methods or functions you want. I had a problem because the C++ class
>> overloaded the operator+ method, but there is any easy to fix that in
>> the docs, calling the python wrapper __add__ instead.
>> So far swig is my choice. Boost.python looked good but I simple
>> couldn't get bjam to work!
> Uh, where does it say that you need to use bjam? It works just fine
> outside of that environment... take a look at Fusion
> <http://itamarst.org/software/> for example.
This page calls itself a quickstart but it doesn't say how to build the
shared library or what to do with the "Boost.Python" wrapper:
The next page in the tutorial which is very Windows specific (I don't
use Windows) and doesn't get me from A to B. ie. it should get a
hello.cpp python module but it doesn't. It seems to want me to run
boost in an example directory which is under /usr/share. Not the right
place to be building anything!
This page also doesn't talk about making the wrapper and/or what to name
it, or what to do with it. It only talks about bjam
David J. Grant
D-Wave Systems Inc.
This electronic transmission, and any documents attached hereto, is
confidential. The information is intended only for use by the recipient
named above. If you have received this electronic message in error,
please notify the sender and delete the electronic message. Any
disclosure, copying, distribution, or use of the contents of
information received in error is strictly prohibited.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 334 bytes
Desc: not available
Url : http://www.scipy.net/pipermail/scipy-user/attachments/20041101/c7b40251/david-0001.vcf
More information about the SciPy-user