[Numpy-discussion] Best way to expose std::vector to be used with numpy

Daniele Nicolodi daniele at grinta.net
Tue Oct 14 08:11:25 EDT 2014


On 14/10/14 13:39, Nathaniel Smith wrote:
> If the goal is to have something that works kind of like the new buffer
> protocol but with a wider variety of python versions, then you might
> find the old array interface useful:
> http://docs.scipy.org/doc/numpy/reference/arrays.interface.html
> 
> I always get confused by the history here but I believe that that's the
> numpy-only interface that later got cleaned up and generalized to become
> the new buffer interface. Numpy itself still supports it.

Hello Nathaniel,

thanks for the pointer, that's what I need.

However, reading the documentation you linked, it looks like the new
buffer protocol is also available in Python 2.6, and I don't have the
need to support older versions, and this is confirmed by the python
documentation:

https://docs.python.org/2.7/c-api/buffer.html

So the issue is just on how to tell SWIG to implement this interface in
the wrappers it generates. Does anyone have a pointer to some relevant
documentation or examples?

Thanks!

Cheers,
Daniele




More information about the NumPy-Discussion mailing list