how to convert code that uses cmp to python3

Paul Rubin no.email at nospam.invalid
Sat Apr 9 13:22:50 EDT 2016


Ben Finney <ben+python at benfinney.id.au> writes:
> The ‘cmp’ implementation must decide *at least* between three
> conditions...  The implementation of ‘__lt__’ and the implementation
> of ‘__eq__’ each only need to decide two conditions (true, false).

> If you're saying the latter implementation is somehow *more* expensive
> than the former, I think the implementations are suspect

What is suspect?  It seems natural to be able to distinguish the 3 cases
faster than two separate 2-case comparisons.  The most obvious example
is comparing long strings by scanning left to right.



More information about the Python-list mailing list