On 10/17/07, David A. Wheeler <[EMAIL PROTECTED]> wrote: > class NumberMixinCmp(ComparisonMixin): ... > def cmp(self, other): > if self.x == other.x: return 0 > return (-1 if self.x < other.x else 1)
In the common case the == test will be false. About ~1/2 of the tests will be be <, and half >. It's better then to do: if self.x < other.x: return -1 elif self.x > other.x: return 1 else: return 0 This almost halves the time difference, as you would expect. -- Adam Hupp | http://hupp.org/adam/ _______________________________________________ Python-3000 mailing list Python-3000@python.org http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com