[issue3051] heapq change breaking compatibility

Raymond Hettinger report at bugs.python.org
Fri Jun 6 22:17:51 CEST 2008


Raymond Hettinger <rhettinger at users.sourceforge.net> added the comment:

I'll fix this to accommodate both cases, __lt__ and __le__. After 
trying x<y and finding the comparison isn't defined, it can try (not 
y<=x) instead.

Also, will document that either __cmp__ or all six rich comparisons 
should be defined for code that wants to run through sort, bisect, 
min/max, or heapq.  The rich comparison PEP is clear on this point, but 
I don't think the affirmative statement ever made it to main docs:

"The reflexivity rules *are* assumed by Python.  Thus, the
interpreter may swap y>x with x<y, y>=x with x<=y, and may swap
the arguments of x==y and x!=y."  -- PEP 207

----------
priority:  -> high

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue3051>
_______________________________________


More information about the Python-bugs-list mailing list