2008/11/1 Greg Landrum <[EMAIL PROTECTED]>

> On Sat, Nov 1, 2008 at 4:48 AM, Alan Baljeu <[EMAIL PROTECTED]> wrote:
> >
> > It was a personal question.  Do you specifically do much wrapping stuff
> or not?  I'm
> > trying to gauge your approach compared to how much you do it.  I mean, if
> I had
> > to wrap one C++ function I would of course use the Python API.  If I had
> to grab 2000
> > classes, I would look for something else to help.  What's the breaking
> point?  How
> > quickly does it go for you?
>
> People are obviously going to have different pain points. I use
> straight boost.python to wrap C++ classes and functions, not any of
> the wrapper generators like SWIG or Py++. I find that doing things by
> hand helps me end up with a more "pythonic" wrapper. If I had to deal
> with a large existing class library, I'd probably go a different route
> and use a generator.


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.


> There's an interesting question about whether it's better to use
> boost.python or SWIG. I've been using boost.python for years, so I
> have a lot invested in it, but if I were starting from scratch, I
> might consider using SWIG because it gives you the flexibility to
> generate wrappers for languages other than Python.


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.


>
>
> an aside: you do not need gcc or cygwin to use boost.python by itself.
> It works fine with visual studio.


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 ;-)

http://pybindgen.googlecode.com/svn/trunk/apidocs/index.html

-- 
Gustavo J. A. M. Carneiro
INESC Porto, Telecommunications and Multimedia Unit
"The universe is always one step beyond logic." -- Frank Herbert
_______________________________________________
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig

Reply via email to