[Numpy-discussion] Creating a bool array with Cython
Keith Goodman
kwgoodman@gmail....
Sat Feb 25 17:26:02 CST 2012
Is this a reasonable (and fast) way to create a bool array in cython?
def makebool():
cdef:
int n = 2
np.npy_intp *dims = [n]
np.ndarray[np.uint8_t, ndim=1] a
a = PyArray_EMPTY(1, dims, NPY_UINT8, 0)
a[0] = 1
a[1] = 0
a.dtype = np.bool
return a
Will a numpy bool array be np.uint8 on all platforms?
How can I do a.dtype=np.bool using the numpy C api? Is there any point
(speed) in doing so?
More information about the NumPy-Discussion
mailing list