Eric Firing wrote:
> Eric Firing wrote:
>> In writing a cython extension to work with numpy masked arrays, I
>> needed to work with the mask, which is dtype('bool'). Therefore I
>> was expecting to be able to use np.bool_t, in analogy to np.float_t.
>> Instead I had to use np.int8_t, and cast the input to np.int8 in a
>> python wrapper. Can bool_t be added to numpy.pxd?
>>
>> Thanks.
>>
>> Eric
The reason it is not there is that AFAIK Cython has no support for an
8-bit boolean type. I.e. you want
print arr[3] # should print "True", not 1.
and furthermore you want
arr[3] = obj # should mean arr[3] = bool(obj)
Which brings up the questions
1) I suppose the best thing would be to add support for a "bool" which
would be a C99 _Bool if compiling on C99, and "unsigned char" with
appropriate restrictions otherwise. Thoughts?
2) Is it better to keep ndarray[bool_t] disabled until this happens, or
should it be enabled (as an "unsigned char" array) and then change its
semantics later?
>
> Attached is a diff that I think takes care of adding bool support.
Thanks, I might apply it depending on the answers I get to the above
questions.
Dag Sverre
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev