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


Groups > comp.lang.python > #106687

Re: how to convert code that uses cmp to python3

From Random832 <random832@fastmail.com>
Newsgroups comp.lang.python
Subject Re: how to convert code that uses cmp to python3
Date 2016-04-08 10:29 -0400
Message-ID <mailman.90.1460125759.2253.python-list@python.org> (permalink)
References (4 earlier) <57075F43.7060004@rece.vub.ac.be> <85fuuw5ypl.fsf@benfinney.id.au> <5707B2CE.1010407@rece.vub.ac.be> <CAPTjJmrMv5O5vwrbfHJJCdiHi87naPOanhPmk4Ba_SLRgu1m4Q@mail.gmail.com> <1460125750.1451220.572931817.3E46D651@webmail.messagingengine.com>

Show all headers | View raw


On Fri, Apr 8, 2016, at 10:08, Chris Angelico wrote:
> seq1 == seq2
> seq1 < seq2
> 
> You only need ONE comparison, and the other is presumed to be its
> opposite. When, in the Python 3 version, would you need to compare
> twice?

== might be just as expensive as the others, particularly if the
sequences are unlikely to share object identity. I suspect he chose "s1
< s2; s2 < s1" precisely because someone suggested in another post on
this thread to exclusively use the less-than operator on purity grounds.

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


Thread

Re: how to convert code that uses cmp to python3 Random832 <random832@fastmail.com> - 2016-04-08 10:29 -0400

csiph-web