Message289422
Does this work with wacky code like this?
@functools.total_ordering
class ClassAssignmentCanBreakChecks():
def __init__(self, i):
self._i = i
def __lt__ (self, other):
last.__class__ = OrdinaryOldInteger
return self._i < (other._i if hasattr(other, '_i') else other)
@functools.total_ordering
class OrdinaryOldInteger:
def __init__(self, i):
self._i = i
def __lt__(self, other):
return self._i < (other._i if hasattr(other, '_i') else other)
lst = [ClassAssignmentCanBreakChecks(i) for i in range(10)]
random.shuffle(lst)
last = lst[-1]
lst.sort()
It looks like it will initially say that all are the same type, and attempt that optimization, which will probably lead to unexpected results as that condition is no longer true after the first compare. |
|
Date |
User |
Action |
Args |
2017-03-11 00:08:37 | ppperry | set | recipients:
+ ppperry, tim.peters, vstinner, serhiy.storchaka, mdk, elliot.gorokhovsky |
2017-03-11 00:08:37 | ppperry | set | messageid: <1489190917.06.0.311868687218.issue28685@psf.upfronthosting.co.za> |
2017-03-11 00:08:37 | ppperry | link | issue28685 messages |
2017-03-11 00:08:36 | ppperry | create | |
|