Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #106748

Re: how to convert code that uses cmp to python3

From Paul Rubin <no.email@nospam.invalid>
Newsgroups comp.lang.python
Subject Re: how to convert code that uses cmp to python3
Date 2016-04-09 10:22 -0700
Organization A noiseless patient Spider
Message-ID <87a8l2ofx1.fsf@nightsong.com> (permalink)
References (8 earlier) <5707BE18.1050805@rece.vub.ac.be> <CAPTjJmoMuqwg0Q_fp=qitC3wWkXYHtdqBNVGzO+3ToAmsgit8Q@mail.gmail.com> <5708C8B0.6050904@rece.vub.ac.be> <85twjb3su5.fsf@benfinney.id.au> <mailman.115.1460202579.2253.python-list@python.org>

Show all headers | View raw


Ben Finney <ben+python@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.

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Re: how to convert code that uses cmp to python3 Ben Finney <ben+python@benfinney.id.au> - 2016-04-09 21:49 +1000
  Re: how to convert code that uses cmp to python3 Paul Rubin <no.email@nospam.invalid> - 2016-04-09 10:22 -0700

csiph-web