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

David Abrahams dave at boost-consulting.com
Sun Sep 15 01:22:36 CEST 2002

From: "eric jones" <eric at enthought.com>

> Hey Mark,
> > 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.
> > They keep talking about Pythonic C++ classes, but I think that
> > limiting inline C++ to such classes will severely limit Weave.
> What is this "severe limitation"?  I just don't understand.  Do you have
> a use case to help me out here?
> We have a very light weight need -- making dicts, tuples, and lists easy
> to use in C++ so that inline C++ code looks as much like Python as
> possible.  This is about 0.3% of boost's capabilities.

I agreed with that at first, but on second thought, well, maybe not. The
capability draws on Boost.Python's core C++<=>Python conversion mechanism,
which accounts for most of the hard stuff in the library.

> On the other
> hand, it uses about 95% of SCXX capabilities which means it is a good
> fit.  SCXX is 900 lines of code and easy to port anywhere.

If that's true, I doubt it's accomplishing the job as well as Boost.Python
does. Note that you never have to explicitly convert C++ objects to Python
when they are interacting with a Python object:

  object f(boost::python::object x)
    x[1] = "hello";
    return x(1,2,3,4,5,6,x); // __call__


    x[Py::Int(1)] = Py::Str("hello");
    // ??? what does __call__ look like?

or whatever. Getting this code to work everywhere was one of the harder
porting jobs I've ever faced. Compilers seem to have lots of bugs in the
areas I was exercising.

However, you may still be right that it's not an appropriate solution for

> If you need the other 99.7% of boost's capabilities, then you probably
> need to be using boost instead of weave anyhow.  They serve different
> purposes.  Weave is generally suited for light weight wrapping and
> speeding up computational kernels with minimum hassle -- especially in
> numeric codes where Numeric isn't fast enough.
> Oh, and I'm happy to except patches that allow for boost type converters
> in weave (they should, after all, be easy to write).  Then you can use
> boost instead of SCXX.

What did you have in mind?

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

More information about the Cplusplus-sig mailing list