[Numpy-discussion] how to work with numpy.int8 in c

Francesc Alted faltet@pytables....
Wed Mar 3 02:33:56 CST 2010


A Wednesday 03 March 2010 02:58:31 David Cournapeau escrigué:
> > PyObject *ret;
> > PyArray_Descr *typecode;
> >
> >
> > typecode = PyArray_DescrFromType(PyArray_UINT8);
> > ret = PyArray_Scalar(NULL, typecode, NULL);
> > Py_DECREF(typecode);
> 
> ^^^^ Sorry, this is wrong, this does not work on my machine, but I am
> not sure to understand why.

Well, at least the next works in Cython:

cdef npy_int8 next
cdef dtype int8
cdef object current

[...]
int8 = PyArray_DescrFromType(NPY_INT8)
current = PyArray_Scalar(&next, int8, None)


-- 
Francesc Alted


More information about the NumPy-Discussion mailing list