Message393087
> 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. |
|
Date |
User |
Action |
Args |
2021-05-06 12:40:30 | mark.dickinson | set | recipients:
+ mark.dickinson, tim.peters, rhettinger, scoder, christian.heimes, steven.daprano, PedanticHacker |
2021-05-06 12:40:30 | mark.dickinson | set | messageid: <1620304830.27.0.317203471994.issue44054@roundup.psfhosted.org> |
2021-05-06 12:40:30 | mark.dickinson | link | issue44054 messages |
2021-05-06 12:40:29 | mark.dickinson | create | |
|