<br><br><div class="gmail_quote">2008/11/1 Greg Landrum <span dir="ltr">&lt;<a href="mailto:greg.landrum@gmail.com">greg.landrum@gmail.com</a>&gt;</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 &lt;<a href="mailto:alanbaljeu@yahoo.com">alanbaljeu@yahoo.com</a>&gt; wrote:<br>
&gt;<br>
&gt; It was a personal question. &nbsp;Do you specifically do much wrapping stuff or not? &nbsp;I&#39;m<br>
&gt; trying to gauge your approach compared to how much you do it. &nbsp;I mean, if I had<br>
&gt; to wrap one C++ function I would of course use the Python API. &nbsp;If I had to grab 2000<br>
&gt; classes, I would look for something else to help. &nbsp;What&#39;s the breaking point? &nbsp;How<br>
&gt; 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 &quot;pythonic&quot; wrapper. If I had to deal<br>
with a large existing class library, I&#39;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.&nbsp; I recommend PyBindGen for people that dislike the kind of C++ template abuse that boost.python does.&nbsp; 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&#39;s an interesting question about whether it&#39;s better to use<br>
boost.python or SWIG. I&#39;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.&nbsp; The C code generated by SWIG is Python builtin module providing a bunch of _functions_, not classes and methods.&nbsp; Then another module is generated on top, Python code, which &quot;adapts&quot; the functional C module to make it look more object oriented.<br>
&nbsp;</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).&nbsp; You only need (py)gccxml for scanning code, not for generating.&nbsp; And generated code does not require any library to compile.&nbsp; And you can even skip (py)gccxml if you want API definitions &quot;by hand&quot;, and this way depend only on pybindgen and python for code generation.&nbsp; 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>
&quot;The universe is always one step beyond logic.&quot; -- Frank Herbert<br>