[C++-sig] approaching a new library

David Abrahams dave at boost-consulting.com
Wed Aug 21 04:03:13 CEST 2002

From: "Leonardo Rochael Almeida" <leo at hiper.com.br>

> Dang, I changed the subject just to send an e-mail that doesn't match
> said subject...
> I meant (but forgot) to ask, do you guys have suggestions regarding how
> to approach a large C++ library with the intent of creating Boost.Python
> bindings for it? any war stories :-)? Since we will be in a position to
> influence changes in the library itself, do you have any suggestions in
> that area? What can a C++ library author do to make it easier to make
> Boost.Python bindings for it?

Fortunately, Boost.Python is designed to be non-intrusive. In general, you
shoudn't need to touch the internals of the library you're wrapping --
that's a design goal.

There are a few areas which can make a difference, however:

1. If you have non-pure virtual functions which you want to be overridable
from Python, make them protected rather than private. It's an unfortunate
limitation that we can't generate a call to the default implementation if
it's private.

2. Exercise some discipline in your use of raw pointers in interfaces. This
is actually much less of an issue with v2 since CallPolicies allows users
to say something about the meaning of pointer arguments and returns, but in
general you're better off if you can work with smart pointers rather than
raw pointers. That's pretty much true of all good C++ code anyway, so it
shouldn't be much of a burden ;-)


           David Abrahams * Boost Consulting
dave at boost-consulting.com * http://www.boost-consulting.com

More information about the Cplusplus-sig mailing list