Meador Inge <mead...@gmail.com> added the comment:

> For a complex number z and an integer i, 'z == i' should be exactly 
> equivalent to 'z.real == i and z.imag == 0.0'.

Like you mentioned before a lot of care is taken in 'floatobject.c' to ensure 
that the comparison is robust.  Would it be a good approach to leverage that 
work?

I have attached a patch with that idea.  If it seems reasonable, then I can 
clean it up and add more tests.  I created the patch for py3k.  I think the 2.x 
changes will be slightly different due to the coercion aspects.

One of the unit tests ('test_complex.test_richcompare') explicitly checks for 
the overflow.  However, the approach of just having the comparison return 
'False' in these cases is more robust.  Is there any use case for explicitly 
notifying of overflow with comparisons?  It seems like more of an 
implementation artifact to me...

----------
keywords: +patch
nosy: +minge
Added file: http://bugs.python.org/file17402/issue-8748.patch

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue8748>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to