This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author mark.dickinson
Recipients PedanticHacker, christian.heimes, mark.dickinson, rhettinger, scoder, steven.daprano, tim.peters
Date 2021-05-06.12:40:29
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1620304830.27.0.317203471994.issue44054@roundup.psfhosted.org>
In-reply-to
Content
> But the way I would have expected this to work is that a comparison of an integer to a float would first convert the integer to a float

I have a vague memory that that's the way it *did* work once upon a time, many many decades ago. But an equality comparison between int and float that simply converted the int to a float would break transitivity of equality, leading to issues with containment in sets, dicts and lists. Given

n = 2**53
x = 2.**53

if equality comparison worked as you describe you'd have n == x and x == n + 1, so to keep transitivity you'd have to make n == n + 1.

In short, the behaviour is very much deliberate.

> That's also what the code says.

Do you have a pointer? This may be a comment bug.
History
Date User Action Args
2021-05-06 12:40:30mark.dickinsonsetrecipients: + mark.dickinson, tim.peters, rhettinger, scoder, christian.heimes, steven.daprano, PedanticHacker
2021-05-06 12:40:30mark.dickinsonsetmessageid: <1620304830.27.0.317203471994.issue44054@roundup.psfhosted.org>
2021-05-06 12:40:30mark.dickinsonlinkissue44054 messages
2021-05-06 12:40:29mark.dickinsoncreate