[Numpy-discussion] Creating a bool array with Cython
Neal Becker
ndbecker2@gmail....
Sun Feb 26 08:52:16 CST 2012
Keith Goodman wrote:
> 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?
Cython has it's own mail lists - maybe you can find more answers there.
More information about the NumPy-Discussion
mailing list