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

David Abrahams dave at boost-consulting.com
Sun Sep 15 04:31:51 CEST 2002

From: "Ralf W. Grosse-Kunstleve" <rwgk at yahoo.com>

> --- David Abrahams <dave at boost-consulting.com> wrote:
> > Boost doesn't provide any facilities for on-demand compilation of C++
> > from Python, if that's what you're getting at.
> Boost.Python is a high-throughput factory for Python "built-in" types.
> of using the few native types (list, tuple, dict) you can easily make
> that are tailored for specific needs.
> I am using Boost.Python in combination with SCons, which is much more
> than the version number suggests. SCons is suitable as a "compilation on
> demand" tool.
> I am wondering how much of a run-time difference it can make if some
> pieces of compiled code working on objects through the (slow b/o dynamic
> typing) Python API are embedded in Python. If speed is a premium you can
> much more if the C++ code operates on native C++ types, without the
overhead of
> the Python API for accessing data items. This is precisely what
> gives you. Typically, I cross the language boundary only once to do an
> "expensive", non trivial operation in pure C++, and the result is a
wrapped C++
> object that can conveniently be inspected from Python.
> Does it make sense to put Weave and Boost.Python together? Let me try an
> analogy: if you choose Weave you are choosing a bicycle, and if you
> Boost.Python you are choosing a car. Obviously the world needs both
> and cars, but would you use a car as a building block for a bicycle?

Ralf, let me stop you before you piss some weave people off ;-). Whether
you intend it or not, this sounds like a potshot against weave.

IIUC, Weave can be used for embedding nontrivial C++ code, if you're
willing to stick it all inside one function body. Furthermore, tools like
weave.blitz() can make an enormous difference by compiling an entire C++
expression template corresponding to an arbitrarily complicated Python
expression. Surely that's nontrivial. It's definitely *cool*.

Though I love bicycles and often hate cars, most people don't see it that
way: they think of the former as less powerful and less robust. What you've
written could easily sound as though it's trivializing weave. I think weave
offers enormous power to the person who's programming mostly in Python.

Actually, it might not be a bad idea to think about merging them, if you
consider weave.blitz. Blitz++ was a pioneering effort in metaprogramming.
Boost.Python is a next-generation metaprogramming framework. There are
definitely some interesting possibilities here.

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

More information about the Cplusplus-sig mailing list