[Numpy-discussion] Testing the python buffer protocol (bf_getbuffer / tp_as_buffer)

Pauli Virtanen pav at iki.fi
Sat Dec 17 20:18:30 EST 2011

18.12.2011 00:49, Soeren Sonnenburg kirjoitti:
> I've looked at the source code of numpy 1.6.1 and couldn't find the
> respective code... I guess I must be doing something wrong but there
> really was no call to PyObject_CheckBuffer() ...

Look for PyObject_GetBuffer

> The problem is I don't really know what is supposed to happen if the new
> buffer protocol is supported by some class named say Foo. Could I then
> do
> x=Foo([1,2,3])
> numpy.array([2,2,2])+x
> and such operations?

Yes. You can try it out with Python's builtin memoryview class.

Pauli Virtanen

More information about the NumPy-Discussion mailing list