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


Groups > comp.lang.python > #106661

Re: how to convert code that uses cmp to python3

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 09:45:54 +0200
Lines 20
Message-ID <mailman.71.1460101559.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> <85wpo95dpo.fsf@benfinney.id.au> <570761B2.3060800@rece.vub.ac.be>
Mime-Version 1.0
Content-Type text/plain; charset=utf-8
Content-Transfer-Encoding 8bit
X-Trace news.uni-berlin.de XpkNBfgRbeXCgf93QhMXSwaVECgQgLpyXFHVuCyeWxLg==
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.005
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'essentially': 0.04; 'cache': 0.05; 'received:134': 0.05; 'subject:code': 0.07; 'api': 0.09; 'describing': 0.16; 'enough?': 0.16; 'operators.': 0.16; 'received:ac.be': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'subject:python3': 0.16; 'traverse': 0.16; 'twice.': 0.16; 'tuples': 0.22; 'second': 0.24; 'header:In-Reply-To:1': 0.24; 'header:User-Agent:1': 0.26; 'comparison': 0.29; 'subject:that': 0.29; 'received:be': 0.30; 'expensive': 0.32; "i'll": 0.33; 'equal': 0.34; 'add': 0.34; 'could': 0.35; 'cases': 0.36; 'to:addr :python-list': 0.36; 'subject:: ': 0.37; 'two': 0.37; 'method': 0.37; 'thought': 0.37; 'to:addr:python.org': 0.40; 'avoid': 0.61; '\xe2\x80\x93': 0.72; 'pardon': 0.84; 'schreef': 0.84; 'look.': 0.91
X-IronPort-Anti-Spam-Filtered true
X-IronPort-Anti-Spam-Result AiENAPhgB1eGuA9G/2dsb2JhbABdhFMBM7xHhg0CggUBAQEBAQFmhGkBAQMBIw8BRQYLCxoCBRYLAgIJAwIBAgFFEwYCAogbCLAwjTSEWgELHnyFJYRLhQuCNIJWBZgEgVSMOIkrhWKPJWKDaWoBiTgBAQE
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Icedove/38.7.0
In-Reply-To <85wpo95dpo.fsf@benfinney.id.au>
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 <570761B2.3060800@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> <85wpo95dpo.fsf@benfinney.id.au>
Xref csiph.com comp.lang.python:106661

Show key headers only | View raw


Op 07-04-16 om 23:08 schreef Ben Finney:
> Antoon Pardon <antoon.pardon@rece.vub.ac.be> writes:
>
>> With this method I have to traverse the two tuples almost always
>> twice. Once to find out if they are equal and if not a second time to
>> find out which is greater.
> You are essentially describing the new internal API of comparison
> operators. That's pretty much unavoidable.

And nobody thought about this kind of cases or found them important enough?

> If you want to avoid repeating an expensive operation – the computation
> of the comparison value for an object – you could add an LRU cache to
> that function. See ‘functools.lru_cache’.

I'll have a look.

-- 
Antoon

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


Thread

Re: how to convert code that uses cmp to python3 Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2016-04-08 09:45 +0200
  Re: how to convert code that uses cmp to python3 Steven D'Aprano <steve@pearwood.info> - 2016-04-08 22:07 +1000
    Re: how to convert code that uses cmp to python3 Marko Rauhamaa <marko@pacujo.net> - 2016-04-08 15:52 +0300

csiph-web