[C++-sig] boost.python and std::valarray

Roman Yakovenko roman.yakovenko at gmail.com
Tue Nov 29 06:27:03 CET 2005


On 11/29/05, Trevor Tippetts <tippetts at lanl.gov> wrote:
> I'm relatively new (and very impressed) user of boost.python. I do have
> a question, however. When I try to access members typed in c++ as
> std::valarray<> in python, I get errors like this:
>
> No Python class registered for C++ class std::valarray<int>
>
> After searching through list archives and online docs and wikis, I have
> come to the conclusion that pyste and boost.python do not have a
> built-in wrapper for std::valarray<> and std::vector<> types. Is that a
> correct assumption?

Partial, boost.python have this:

http://boost.org/libs/python/doc/v2/indexing.html

Also you can write ( and contribute ) template class similar to
indexing_suite::Container
that will expose std::valarray to python.

An other valid approach, is to copy std::valarray to
boost::python::list and return it.

See http://boost.org/libs/python/pyste/doc/wrappers.html

> I found some examples people have given for wrapping std::vector<>, but
> not for std::valarray<>. Does anyone know of a good example
> implementation to which the rest of us could refer?
>
> Thanks,
> Trevor



More information about the Cplusplus-sig mailing list