1 Jul 02:26
[Cython] accessing ctype array's b_ptr
Hi,
I need to access ctype array's b_ptr. The array is defined in
Python-2.6.2/Modules/_ctypes/ctypes.h as:
struct tagCDataObject {
PyObject_HEAD
char *b_ptr; /* pointer to memory block */
int b_needsfree; /* need _we_ free the memory? */
CDataObject *b_base; /* pointer to base object or NULL */
Py_ssize_t b_size; /* size of memory block in bytes */
Py_ssize_t b_length; /* number of references we need */
Py_ssize_t b_index; /* index of this object into base's
b_object list */
PyObject *b_objects; /* dictionary of references we need to
keep, or Py_None */
union value b_value;
};
So I wrote this cython code:
cdef extern from "Python.h":
ctypedef void PyTypeObject
cdef struct CDataObject:
Py_ssize_t ob_refcnt
PyTypeObject *ob_type
char *b_ptr
and then I use it like this:
(Continue reading)
RSS Feed