[Numpy-discussion] Best way to expose std::vector to be used with numpy
stefan at seefeld.name
Tue Oct 14 03:02:14 EDT 2014
On Oct 14, 2014 4:40 AM, "Charles R Harris" <charlesr.harris at gmail.com>
> On Mon, Oct 13, 2014 at 12:54 PM, Sebastian Berg <
sebastian at sipsolutions.net> wrote:
>> On Mo, 2014-10-13 at 13:35 +0200, Daniele Nicolodi wrote:
>> > Hello,
>> > I have a C++ application that collects float, int or complex data in a
>> > possibly quite large std::vector. The application has some SWIG
>> > generated python wrappers that expose this vector to python. However,
>> > the standard way in which SWIG exposes the data is to create a touple
>> > and pass this to python, where it is very often converted to a numpy
>> > array for processing. Of course this is not efficient.
>> > I would like therefore to generate a smarter python interface. In
>> > 3 I would without doubt go for implementing the buffer protocol, which
>> > enables seamless interfacing with numpy. However, I need to support
>> > python 2 and there the buffer protocol is not as nice.
>> Isn't the new buffer protocol in python 2.6 or 2.7 already? There is at
>> least a memoryview object in python 2, which maybe could be used to the
>> same effect?
> No memoryview in python2.6, but the older buffer protocol it there. Is
Boost Python an option?
Boost.Numpy may be a useful tool to use here.
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the NumPy-Discussion