On Thu, Apr 7, 2016 at 8:46 AM, Antoine Pitrou <solipsis@pitrou.net> wrote:
Booleans currently have reasonable overrides for the bitwise binary operators:
True | False True True & False False True ^ False True
All those are consistent with bool being a subclass of int, in the sense that (for example) `int(True | False)` is identical to `int(True) | int(False)`. Redefining ~True to be False wouldn't preserve that: int(~True) == ~int(True) would become invalid. In short, the proposal would break the Liskov Substitution Principle. (The obvious fix is of course to make True have value -1 rather than 1. Then everything's consistent. No, I'm not seriously suggesting this - the amount of breakage would be insane.) NumPy has the luxury that numpy.bool_ is *not* a subclass of any integer type. Mark