Message289447
What about if one of the relevant comparison functions is implemented in C?
class WackyComparator(int):
def __lt__(self, other):
elem.__class__ = WackyList2
return int.__lt__(self, other)
class WackyList1(list):pass
class WackyList2(list):
def __lt__(self, other):
raise ValueError
lst =
list(map(WackyList1,[[WackyComparator(3),5],[WackyComparator(4),6],[WackyComparator(7),7]]))
random.shuffle(lst)
elem = lst[-1]
lst.sort()
This code raises ValueError, and caching seems like it would cache the
comparator for WackyList1 objects, which is the same as the comparator for
'list' objects -- and midway through comparison, one of them changes type
to WackyList2, which has its own (broken) comparison function.
Python is very very dynamic ... |
|
Date |
User |
Action |
Args |
2017-03-11 15:12:31 | ppperry | set | recipients:
+ ppperry, tim.peters, vstinner, serhiy.storchaka, mdk, elliot.gorokhovsky |
2017-03-11 15:12:31 | ppperry | link | issue28685 messages |
2017-03-11 15:12:30 | ppperry | create | |
|