[Numpy-discussion] ctypes and NumPy

Albert Strasheim fullung at gmail.com
Fri May 5 19:49:04 EDT 2006


Hello all

After some more playing with ctypes, I've come up with some ideas of using
ctypes with NumPy without having to change ndarray. Info on the wiki:

http://www.scipy.org/Cookbook/Ctypes

I've figured out how to overlay ctypes onto NumPy arrays. Used in
conjunction with decorators, this offers a reasonably seamless way of
passing NumPy arrays through ctypes to C functions.

I have some ideas for doing the reverse, i.e. overlaying NumPy arrays onto
ctypes, but I haven't been able to get this to work yet. Any suggestions in
this area would be appreciated.

It is useful to be able to do this when you have a function returning
something like a double*. In this case you probably have some knowledge
about the size of this buffer, so you can construct an array with the right
dtype and shape to work further on this array.

Regards,

Albert





More information about the NumPy-Discussion mailing list