[Numpy-discussion] Should bool_ subclass int?
Sat Jul 7 00:45:01 CDT 2007
Timothy Hochberg wrote:
> I'm working on getting some old code working with numpy and I noticed
> that bool_ is not a subclass of int. Given that python's bool
> subclasses into and that the other scalar types are subclasses of
> their respective counterparts it seems at first glance that
> numpy.bool_ should subclass python's bool, which in turn subclasses
> int. Or am I missing something here?
The reason it is not, is because it is not binary compatible with
Python's integer. The numpy bool_ is always only 8-bits while the
Python integer is 32-bits or 64-bits.
This could be changed I suspect, but then it would break the
relationship between scalars and their array counterparts and I'm sure
we would not want to bump up all bool arrays to 32 or 64-bits.
More information about the Numpy-discussion