[C++-sig] weave plus boost?

eric eric at enthought.com
Sun Jan 20 03:28:13 CET 2002


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.

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.
I'd like to hear opinions on the subject.  The type conversions in weave are
actually "pluggable", so I expect in the end there will be conversion
classes for using CXX, SCXX, raw PyObject* pointers, and boost allowing the
user to choose what he/she likes best.

To close, I'll provide a couple of trivial examples of how weave works now.
Hopefully that'll give some people ideas on how boost might improve the
tool:

>>> import weave
>>> a = 1
>>> weave.inline('std::cout << a << std::endl;',['a'])
1
>>> a = 'string'
>>> weave.inline('std::cout << a << std::endl;',['a'])
string

--------------------------------------------------------

>>> from weave import ext_tools
>>> m = ext_tools.ext_module('test_mod')
>>> a = 1
>>> code = 'return_val = Py::new_reference_to(Py::Int(a+1));'
>>> f = ext_tools.ext_function('func', code, ['a'])
>>> m.add_function(f)
>>> m.compile()
>>> import test_mod
>>> test_mod.func(2)
3

I look forward to a conversation.

thanks,
eric

--
Eric Jones <eric at enthought.com>
Enthought, Inc. [www.enthought.com and www.scipy.org]
(512) 536-1057







More information about the Cplusplus-sig mailing list