Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #106681
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: how to convert code that uses cmp to python3 |
| Date | 2016-04-09 00:08 +1000 |
| Message-ID | <mailman.84.1460124521.2253.python-list@python.org> (permalink) |
| References | (3 earlier) <CAPTjJmrbL870mV1kU8nHar=bPyKZRmhKP-8iUs_tpYVo5vhhOA@mail.gmail.com> <57075F43.7060004@rece.vub.ac.be> <85fuuw5ypl.fsf@benfinney.id.au> <5707B2CE.1010407@rece.vub.ac.be> <CAPTjJmrMv5O5vwrbfHJJCdiHi87naPOanhPmk4Ba_SLRgu1m4Q@mail.gmail.com> |
On Fri, Apr 8, 2016 at 11:31 PM, Antoon Pardon <antoon.pardon@rece.vub.ac.be> wrote: > Doing it as follows: > seq1 < seq2 > seq2 < seq1 > > takes about 110 seconds. > > > Doing it like this: > delta = cmp(seq1, seq2) > delta < 0 > delta > 0 > > takes about 50 seconds. Why are you comparing in both directions, though? cmp() is more equivalent to this: 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? ChrisA
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: how to convert code that uses cmp to python3 Chris Angelico <rosuav@gmail.com> - 2016-04-09 00:08 +1000
csiph-web