[issue36117] Allow rich comparisons for real-valued complex objects.

Brandt Bucher report at bugs.python.org
Tue Feb 26 09:37:55 EST 2019


Brandt Bucher <brandtbucher at gmail.com> added the comment:

> The rules for when things are comparable or not should be kept simple.

I think that the sort of user who uses complex numbers for their numerical calculations would still find this behavior "simple", but that may just be me.

> We don't want to have objects that are orderable depending on their values. I can't think of anywhere else we do this.

Well... tuples and lists behave this way. ;)

> An application relying on this would be a nightmare to write comprehensive tests for.

I'm not arguing that applications should rely on this behavior as core functionality, just that Python's more advanced math functionality deserves to be correct.

With that said, there are already so many weird limitations on complex numbers and floating-point values in general. I wouldn't expect users to treat comparing complex numbers any differently than they would treat comparing floats. Check check the .imag value in the former, check math.isnan in the latter.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue36117>
_______________________________________


More information about the Python-bugs-list mailing list