[Numpy-discussion] Should bool_ subclass int?
Charles R Harris
charlesr.harris at gmail.com
Tue Jul 10 12:53:22 EDT 2007
On 7/10/07, Timothy Hochberg <tim.hochberg at ieee.org> wrote:
> [CHOP: lots of examples]
> It looks like bool_s could use some general rejiggering. Let me put forth
> a concrete proposal that's based on matching bool_ behaviour to that of
> Python's bools. There is another route that could be taken where bool_ and
> bool are completely decoupled, but I'll skip over that for now since I don't
> really think it's a good idea.
> 1. +,- are arithmetic operators and return ints not booleans
> 2. *,** are arithmetic operators on scalars and arrays and return
> ints as above.
> 3. &,|,^ are the logical operators and return booleans.
> 4. *,** are defined on matrices to perform logical matrix
> multiplication and exponation.
> This seems like the simplest route towards something that is both
> internally self consistent and consistent with Python.
Looks good to me. At least it would make things consistent with bool_ being
a subclass of integers if we go that way.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the NumPy-Discussion