[Numpy-discussion] Ctypes support in NumPy

Travis Oliphant oliphant.travis at ieee.org
Sat Jul 1 22:19:57 CDT 2006


I've been playing a bit with ctypes and realized that with a little 
help, it could be made much easier to interface with NumPy arrays.  
Thus, I added a ctypes attribute to the NumPy array.  If ctypes is 
installed, this attribute returns a "conversion" object otherwise an 
AttributeError is raised.

The ctypes-conversion object has attributes which return c_types aware 
objects so that the information can be passed directly to c-code (as an 
integer, the number of dimensions can already be passed using c-types).

The information available and it's corresponding c_type is

data           -  c_void_p
shape, strides -  c_int * nd  or c_long * nd or c_longlong * nd 
depending on platform

-Travis








More information about the Numpy-discussion mailing list