Accessing data buffers in numpy scalars

Francesc Altet faltet at carabos.com
Tue Oct 17 11:07:19 CDT 2006


Hi,

I'm looking for an easy way to access the data area of the numpy scalars no 
matter its type.  I've seen that numpy/arrayscalars.h define a structure for 
each scalar type, so I'd guess that it will not be possible to find a general 
way for accessing the data buffer for each type. So, I've decided to look for 
a workaround and I've devised a couple of possibilities:

1.- Promote the scalar type to a ndarray object and use the regular ndarray C 
structure to access the data buffer.

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.

If there is some other trivial way that I haven't devised (specially if usable 
from pyrex), please tell me about.

TIA,

-- 
>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