Author mark.dickinson
Recipients docs@python, mark.dickinson
Date 2020-02-02.14:17:34
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1580653054.78.0.127921454413.issue39530@roundup.psfhosted.org>
In-reply-to
Content
The documentation[1] for comparisons between mixed types says:

> [...] when a binary arithmetic operator has operands of different
> numeric types, the operand with the "narrower" type is widened to
> that of the other, where integer is narrower than floating point,
> which is narrower than complex. Comparisons between numbers of
> mixed type use the same rule.

That "use the same rule" part of the last sentence is misleading: it suggests that (for example) when an int is compared with a float, the int is first converted to a float, and then the two floats are compared. But that's not what actually happens: instead, the exact values of the int and float are compared. (And it's essential that equality comparisons happen that way, else equality becomes intransitive and dictionaries with numeric keys get very confused as a result.)

I suggest dropping the last sentence and adding a new paragraph about comparisons between numbers of mixed type.




[1] https://github.com/python/cpython/blob/master/Doc/library/stdtypes.rst#numeric-types-----classint-classfloat-classcomplex
History
Date User Action Args
2020-02-02 14:17:34mark.dickinsonsetrecipients: + mark.dickinson, docs@python
2020-02-02 14:17:34mark.dickinsonsetmessageid: <1580653054.78.0.127921454413.issue39530@roundup.psfhosted.org>
2020-02-02 14:17:34mark.dickinsonlinkissue39530 messages
2020-02-02 14:17:34mark.dickinsoncreate