[Numpy-discussion] ndarray and the buffer protocol

Fons Adriaensen fons@kokkinizita....
Wed Jul 8 18:15:45 CDT 2009


Hello all,

(resending for the Nth time, as the previous attempts
 didn't make it to the list)

I'm new to this list (and numpy is mostly new to me :-).

Using python 2.6 and numpy 1.3.

My plan is to write some C extensions that will perform
rather specialised processing on multichannel digital audio
data stored stored in numpy arrays.

Sinc 2.6 python has a new buffer protocol, and referring
to this, the numpy website states rather fuzzily:

  Of course, numpy makes a good interoperation library to
  support the buffer protocol. Numpy can both consume and
  produce protocol-supporting objects. A numpy ndarray can
  be constructed as a view of an object supporting the
  buffer protocol, and a numpy ndarray supports buffer
  object views of its data. 

I'd want the C code to be based on using the new buffer
protocol - everything else is marked as 'deprecated', also
in the numpy docs.

But it remains quite unclear if numpy 1.3 does or does not
support this, and if yes, how.

As far as I've been able to find out, calling PyObject_CheckBuffer()
on a numpy array returns zero, indicating that the object does not
support the buffer protocol.

To add to the confusion, the python 2.6 docs say that the
new buffer protocol should also be used to access python's
own array type. But also for this type PyObject_CheckBuffer()
returns zero. 


I'd be very happy is someone could clear the fog...

TIA,


-- 
FA

Io lo dico sempre: l'Italia è troppo stretta e lunga.



More information about the NumPy-Discussion mailing list