Author ppperry
Recipients elliot.gorokhovsky, mdk, ppperry, serhiy.storchaka, tim.peters, vstinner
Date 2017-03-11.03:58:36
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1489204716.4.0.691010220299.issue28685@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2017-03-11 03:58:36ppperrysetrecipients: + ppperry, tim.peters, vstinner, serhiy.storchaka, mdk, elliot.gorokhovsky
2017-03-11 03:58:36ppperrysetmessageid: <1489204716.4.0.691010220299.issue28685@psf.upfronthosting.co.za>
2017-03-11 03:58:36ppperrylinkissue28685 messages
2017-03-11 03:58:36ppperrycreate