[Python-ideas] Should bool continue to inherit from int?

Neil Girdhar mistersheik at gmail.com
Thu Jan 22 09:45:48 CET 2015


What did you expect?  It can't be 2 since np.bool is free to be a one-bit 
type.  It shouldn't promote.  If anything it should probably be False in my 
opinion just like

np.int8(255) + 1 == 0

>From a mathematician's standpoint Booleans are the ring of integers modulo 
2.

On this proposal, I agree with the people saying it's too backwards 
incompatible, but from an ivory tower standpoint it would have been better.

Best,
Neil

On Wednesday, January 21, 2015 at 2:50:00 PM UTC-5, Alexander Belopolsky 
wrote:
>
>
> On Wed, Jan 21, 2015 at 2:11 PM, Guido van Rossum <gu... at python.org 
> <javascript:>> wrote:
>
>> 2) Do most Python users still agree that arithmetic operations should be 
>>> supported on booleans?
>>>
>>  
>> It would be so massively backward compatible that it's not worth thinking 
>> about.
>>
>
> The only time I encountered a situation where True + True was not 2 was in 
> numpy:
>
> >>> numpy.bool_(True) + True
> True
>
> That was *very* inconvenient!
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20150122/a6e6d90b/attachment.html>


More information about the Python-ideas mailing list