[C++-sig] weave plus boost?

David Abrahams david.abrahams at rcn.com
Mon Jan 21 08:20:07 CET 2002


----- Original Message -----
From: "eric" <eric at enthought.com>

> Hey group,
>
> I've just signed up to listen in on the group.  I haven't followed boost
to
> closely, but am interested in catching up with what this community is
doing.
>
> My main interest here is to see if there is anyway that weave can benefit
> from the boost effort -- I'm almost sure there is.  weave
> (www.scipy.org/site_content/weave) is a tool for, among other things,
> inlining C/C++ within Python.  It also has a module called ext_tools that
> allows you to build C/C++ extension modules using Python.  Currently,
> ext_tools only supports building modules that contain functions.  I'd like
> to eventually extend it so that it handles extension classes as well.  It
> looks like it won't be to bad, but boost might make some aspects of this
> more elegant and easier for the end user.

Possibly so.

> Also, currently, weave converts Python containers to CXX List, Tuple, and
> Dict class objects.  I'm strongly considering switching to SCXX because
they
> are quite a bit simpler and more portable.  CXX is a little heavier duty
> than weave really needs.  I expect boost provides another alternative
here.

Yes, it does, although there's no documentation for that part of
Boost.Python yet. The framework for manipulating the built-in Python types
is currently similar to the facility you get from CXX, but Arlnaldur
Gylfason is working on a new design.

A great strength of Boost.Python is its ability to provide extensible
automatic type conversions between Python and C++ without a separate
compilation step. When applied to objects like lists and dicts is that, if
you've got to_python converters for, say my_class and std::vector<double>,
you can write:

int f(myclass const& x, std::vector<double> const& y)
{
    tuple three(1, x, y);
    std::string msg("this is a test");
    dict d;
    d[msg] = 5;
}

...etc.

Boost.Python has a different paradigm than weave does. A principal idea of
Boost.Python is that you should be able to easily expose a standalone
library of C++ types and functions to Python without writing lots of "glue"
(e.g. argument checking and translation) and without intrusive changes to
the library. Weave's orientation seems to be towards writing C++ bodies for
Python functions. It should be very quick for those who don't want to leave
their Python editor just to optimize a function. However, it seems like that
approach wouldn't be very compatible with the idea of a standalone C++
library unless you just plan to write little wads of glue code in weave and
dispatch to your library. It also seems as though it might not scale well,
since (and I'm guessing here) you have to cross a Python function boundary
every time you want to break off a new piece of functionality. I'm not
saying one or the other paradigm is best - they seem to serve different
needs. Whether weave can benefit somehow from Boost.Python isn't clear to
me, but I hope what I've said helps to give you an idea.

-Dave






More information about the Cplusplus-sig mailing list