Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #106683
| Path | csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | Antoon Pardon <antoon.pardon@rece.vub.ac.be> |
| Newsgroups | comp.lang.python |
| Subject | Re: how to convert code that uses cmp to python3 |
| Date | Fri, 8 Apr 2016 16:20:08 +0200 |
| Lines | 36 |
| Message-ID | <mailman.86.1460125230.2253.python-list@python.org> (permalink) |
| References | <57064D0D.1030701@rece.vub.ac.be> <CAPTjJmrGiQS9uhFU-+TQ4nUWQ2p4gmJoQitMotS0Ob--qm1iWg@mail.gmail.com> <5706C961.2000009@rece.vub.ac.be> <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> <5707BE18.1050805@rece.vub.ac.be> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=utf-8 |
| Content-Transfer-Encoding | 7bit |
| X-Trace | news.uni-berlin.de lTX9ZeKHXDOZWwIrylNHcgIWWJDC6Cu4E1A/v+obK8yg== |
| Return-Path | <antoon.pardon@rece.vub.ac.be> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.013 |
| X-Spam-Evidence | '*H*': 0.97; '*S*': 0.00; 'received:134': 0.05; 'subject:code': 0.07; 'python': 0.10; 'argument': 0.15; '2016': 0.16; 'equal.': 0.16; 'received:ac.be': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'seconds.': 0.16; 'subject:python3': 0.16; 'traverse': 0.16; 'wrote:': 0.16; 'comparing': 0.18; 'tree': 0.18; 'delta': 0.22; 'this:': 0.23; 'header:In-Reply-To:1': 0.24; 'header:User-Agent:1': 0.26; "doesn't": 0.26; 'chris': 0.26; 'compare': 0.27; 'equivalent': 0.27; 'fri,': 0.27; 'key,': 0.29; 'node': 0.29; 'subject:that': 0.29; 'received:be': 0.30; 'version,': 0.30; 'follows:': 0.35; 'smaller': 0.36; 'to:addr :python-list': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'doing': 0.38; 'why': 0.39; 'takes': 0.39; 'to:addr:python.org': 0.40; 'more': 0.63; '50%': 0.79; 'angelico:': 0.84; 'difference.': 0.84; 'directions,': 0.84; 'pardon': 0.84; 'schreef': 0.84 |
| X-IronPort-Anti-Spam-Filtered | true |
| X-IronPort-Anti-Spam-Result | Al8LAKO9B1eGuA9G/2dsb2JhbABchFMBM7xGhg0CgX8BAQEBAQFmhGgBAQEDASNVBgsLGAICBRYLAgIJAwIBAgFFEwYCAogbCK5djSiEWgEBCAIefIUlhEuFC4I0glYBBJgEgVSMOIkrhWKPJWKDaWoBiTgBAQE |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Icedove/38.7.0 |
| In-Reply-To | <CAPTjJmrMv5O5vwrbfHJJCdiHi87naPOanhPmk4Ba_SLRgu1m4Q@mail.gmail.com> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.21 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| X-Mailman-Original-Message-ID | <5707BE18.1050805@rece.vub.ac.be> |
| X-Mailman-Original-References | <57064D0D.1030701@rece.vub.ac.be> <CAPTjJmrGiQS9uhFU-+TQ4nUWQ2p4gmJoQitMotS0Ob--qm1iWg@mail.gmail.com> <5706C961.2000009@rece.vub.ac.be> <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> |
| Xref | csiph.com comp.lang.python:106683 |
Show key headers only | View raw
Op 08-04-16 om 16:08 schreef Chris Angelico: > 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 That doesn't make a difference. > 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? About 50% of the time. When I traverse the tree I go left when the argument key is smaller than the node key, I go right when it is greater than the node key and I have found the node I want when they are equal. -- Antoon Pardon
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: how to convert code that uses cmp to python3 Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2016-04-08 16:20 +0200
csiph-web