<br><br><div class="gmail_quote">2008/11/1 Greg Landrum <span dir="ltr"><<a href="mailto:greg.landrum@gmail.com">greg.landrum@gmail.com</a>></span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="Ih2E3d">On Sat, Nov 1, 2008 at 4:48 AM, Alan Baljeu <<a href="mailto:alanbaljeu@yahoo.com">alanbaljeu@yahoo.com</a>> wrote:<br>
><br>
> It was a personal question. Do you specifically do much wrapping stuff or not? I'm<br>
> trying to gauge your approach compared to how much you do it. I mean, if I had<br>
> to wrap one C++ function I would of course use the Python API. If I had to grab 2000<br>
> classes, I would look for something else to help. What's the breaking point? How<br>
> quickly does it go for you?<br>
<br>
</div>People are obviously going to have different pain points. I use<br>
straight boost.python to wrap C++ classes and functions, not any of<br>
the wrapper generators like SWIG or Py++. I find that doing things by<br>
hand helps me end up with a more "pythonic" wrapper. If I had to deal<br>
with a large existing class library, I'd probably go a different route<br>
and use a generator.</blockquote><div><br>My opinion is biased, of course, but I use PyBindGen, usually with the help of pygccxml for automatic scanning. I recommend PyBindGen for people that dislike the kind of C++ template abuse that boost.python does. Of course I also recommend anyone starting with pybindgen to be aware of its limitations, namely lack of support for multiple inheritance and C++ exceptions. <br>
<br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
There's an interesting question about whether it's better to use<br>
boost.python or SWIG. I've been using boost.python for years, so I<br>
have a lot invested in it, but if I were starting from scratch, I<br>
might consider using SWIG because it gives you the flexibility to<br>
generate wrappers for languages other than Python.</blockquote><div><br>On the other hand, SWIG generates ugly and inneficient code, at least for the Python case. The C code generated by SWIG is Python builtin module providing a bunch of _functions_, not classes and methods. Then another module is generated on top, Python code, which "adapts" the functional C module to make it look more object oriented.<br>
</div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
<br>
an aside: you do not need gcc or cygwin to use boost.python by itself.<br>
It works fine with visual studio.</blockquote><div><br>pybindgen generated code also compiles fine with visual studio (or at least the unit test suite does). You only need (py)gccxml for scanning code, not for generating. And generated code does not require any library to compile. And you can even skip (py)gccxml if you want API definitions "by hand", and this way depend only on pybindgen and python for code generation. Finally, pybindgen is a small pure python module of which a copy can easily be included in the project itself ;-)<br>
<br><a href="http://pybindgen.googlecode.com/svn/trunk/apidocs/index.html">http://pybindgen.googlecode.com/svn/trunk/apidocs/index.html</a><br><br></div></div>-- <br>Gustavo J. A. M. Carneiro<br>INESC Porto, Telecommunications and Multimedia Unit<br>
"The universe is always one step beyond logic." -- Frank Herbert<br>