[C++-sig] Status of Numpy support in boost python
Hans Meine
hans_meine at gmx.net
Wed Apr 21 22:36:10 CEST 2010
Am Montag 08 März 2010 13:32:22 schrieb Pim Schellart:
> we are working on a project for which it would be extremely useful if
> numpy arrays could be passed as arguments to wrapped C++ methods.
> On the website I cannot find any evidence that this is currently
> supported by Boost Python.
> Is this (or will this be) implemented?
After all the recent discussion, I want to point to yet another (hopefully)
interesting bit of code which I am involved with:
Our "vigra" (computer vision) library now comes with numpy- and BPL-based
python bindings.
In addition to type-safe conversions between C++ and Python(*), this offers a
vigra::MultiArray on the C++ side, which is an n-dimensional array class
template, complete with n-dimensional iterators (using raw pointers for the
innermost dimension to offer the best possible performance for unstrided
arrays) and a lot of algorithms, i.e. pointwise transformation / [possibly
type-coercing] copying / inspection etc.
One particular feature Ulli is proud of is the automatic conversion to
*subclasses* of ndarray, such that we can register and use e.g. 'Volume'
python classes for 3D arrays.
I really want to stress that VIGRA is a very versatile template library which
should be able to work in conjunction with any other libraries and data
structures, i.e. true generic code (usually you don't even need to compile
VIGRA, if you are not interested in an image import/export library). So don't
hesitate to give it a shot even if you are /not/ interested in any of its
array / linalg algorithms. (Actually, the PythonArray template class should
be even useful without boost::python, i.e. I am using it with SIP, too.)
I don't think there will ever be just /one/ single solution for
boost::python+numpy, since everyone seems to have different
requirements/expectations w.r.t. available algorithms, static vs. dynamic
element types etc.
However, I do think that our vigranumpy approach could be very useful for some
of this list's readers.
HTH,
Hans
-------------- next part --------------
An embedded message was scrubbed...
From: Ullrich Koethe <ullrich.koethe at iwr.uni-heidelberg.de>
Subject: [VIGRA] VIGRA 1.7.0 Released
Date: Thu, 15 Apr 2010 20:58:40 +0200
Size: 4914
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20100421/33c10aec/attachment.mht>
More information about the Cplusplus-sig
mailing list