Accessing data buffers in numpy scalars

Francesc Altet faltet at carabos.com
Tue Oct 17 11:35:59 CDT 2006


A Dimarts 17 Octubre 2006 18:22, Travis Oliphant va escriure:
> >2.- Fetch the buffer in scalartype.data and use the buffer protocol in
> > order to access the pointer to data in memory. However, I lack experience
> > in buffer protocol, so suggestions for achieving this are welcome.
>
> This will also work.   A read-only buffer protocol is exported by all
> the scalars.
>
> scalar.data will return a buffer object.
>
> Or you can use the Python C-API
>
> const char *buffer;
> Py_ssize_t buflen;
>
> PyObject_AsReadBuffer(scalar, (const void **)&buffer, &buflen)

Oh, this one seems pretty easy, and as a plus, you don't have to book memory 
for copying the data area, so I'll use it.

Thanks,

-- 
>0,0<   Francesc Altet     http://www.carabos.com/
V   V   Cárabos Coop. V.   Enjoy Data
 "-"

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642




More information about the Numpy-discussion mailing list