ppperry added the comment:
And what about even wackier code like this?
class A(int):
def __lt__(self, other):
print("zebra")
A.__lt__ = A.__false_lt__
return int.__lt__(self, other)
__true_lt__ = __lt__
def __false_lt__(self, other):
print("gizmo")
A.__lt__ = A.__true_lt__
return int.__lt__(self, other)
[A(i) for i in range(20, 5, -1)].sort()
This alternates printing "zebra" and "gizmo" for every comparison, and there is
no way to add some sort of caching without changing this behavior.
----------
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue28685>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com