[C++-sig] Weave Scipy Inline C++

David Abrahams dave at boost-consulting.com
Sat Sep 14 23:28:03 CEST 2002

From: "Mark Evans" <lists at UltimateG.com>

> http://www.scipy.org/site_content/weave
> Can Boost do anything like this?  These folks are planning to use SCXX
> while I am trying to get them to use Boost Python for C++ interfacing.

Boost doesn't provide any facilities for on-demand compilation of C++ code
from Python, if that's what you're getting at.

> They keep talking about Pythonic C++ classes, but I think that
> limiting inline C++ to such classes will severely limit Weave.

Sorry, I don't understand what you're saying.

> Their statement is:
> Message: 5
> From: "eric jones" <eric at enthought.com>
> To: <scipy-dev at scipy.net>
> Subject: RE: [SciPy-dev] Boost vs CXX and SCXX
> Date: Fri, 13 Sep 2002 14:53:26 -0500
> Reply-To: scipy-dev at scipy.net
> Hey Mark,
> Like you, I'd pick boost or SWIG (which has made *huge* leaps in the
> last year for C++ stuff) for wrapping a C++ library.  But that isn't
> what we're choosing here.  Weave allows you to inline C++ code within
> Python.  It is nice to have a representation of Python objects in the
> C++ code that look Pythonic.  C++ classes allow this sort of thing.

Well, Boost.Python v2 does let you have a reasonably Pythonic
representation of Python objects from C++. See the June progress report at


for details...but I don't see how that relates the the examples below.

> CXX wrappers allowed this sort of thing:
> >>> import weave
> >>> a= [1,2]
> >>> weave.inline('a[0] = Py::Int(3)',['a'])
> >>> a[0]
> [3, 2]
> Now with SCXX, we have:
> >>> import weave
> >>> a = [1,2]
> >>> weave.inline('a[0] = PWONumber(3);',['a'])
> >>> a
> [3, 2]
> I doubt boost would be much different or superior to either of these
> in terms of readability or use.
> As I said before, most of the tools boost provides help with wrapping
> code and aren't beneficial in the context of weave.  All we're looking
> for is a few measly classes for wrapping lists, dicts, and tuples --
> although callable objects, files, and modules are other potential
> targets.  If we can extract these easily from boost, they compile
> easily on everything, and they offer some benefits over these other two
> approachs *in the context of weave*, then its worth considering a
> change.  I'm happy to look at an experimental patch. :-)

Are you trying to change what the weave folks are doing?
Hmm, why?

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

More information about the Cplusplus-sig mailing list