Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.dougwise.org!nntpfeed.proxad.net!proxad.net!feeder1-1.proxad.net!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'terry': 0.07; 'url:bugs': 0.07; 'prevents': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:80.91.229.12': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:lo.gmane.org': 0.09; 'subject:method': 0.09; 'pm,': 0.11; 'output': 0.12; 'wrote:': 0.14; 'functools': 0.16; 'reedy': 0.16; 'situations,': 0.16; 'subject:sort': 0.16; 'code,': 0.20; 'interface': 0.20; 'maybe': 0.21; 'jan': 0.22; 'code': 0.22; 'header:In-Reply-To:1': 0.22; "i'm": 0.26; 'looks': 0.28; 'probably': 0.30; 'least': 0.30; 'comment': 0.30; 'concern.': 0.31; 'does': 0.31; 'paul': 0.32; 'import': 0.32; 'to:addr:python- list': 0.32; 'header:X-Complaints-To:1': 0.34; 'change': 0.34; 'there': 0.35; 'header:User-Agent:1': 0.35; 'put': 0.35; 'function.': 0.35; 'some': 0.37; 'should': 0.37; 'url:python': 0.37; 'but': 0.38; 'url:org': 0.38; 'received:org': 0.38; 'unless': 0.38; 'to:addr:python.org': 0.39; 'could': 0.39; 'header :Mime-Version:1': 0.39; 'would': 0.40; "it's": 0.40; 'header:Received:5': 0.40; 'show': 0.67; 'gain': 0.80; 'subject:removal': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Reedy Subject: Re: Guido rethinking removal of cmp from sort method Date: Fri, 01 Apr 2011 22:21:33 -0400 References: <4d7cbfcb$0$29971$c3e8da3$5496439d@news.astraweb.com> <4d94326c$0$30003$c3e8da3$5496439d@news.astraweb.com> <7x8vvue7or.fsf@ruckus.brouhaha.com> <7xfwq1srn0.fsf@ruckus.brouhaha.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: rain.gmane.org User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.15) Gecko/20110303 Lightning/1.0b2 Thunderbird/3.1.9 In-Reply-To: <7xfwq1srn0.fsf@ruckus.brouhaha.com> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 26 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1301710905 news.xs4all.nl 81483 [::ffff:82.94.164.166]:40039 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:2424 On 4/1/2011 3:22 PM, Paul Rubin wrote: >> 2to3 could probably gain a fixer to change >> .sort(cmp=f) # to >> >> import functools import cmp_to_key >> .sort(key=functools.cmp_to_key(f)) >> >> I know some would not like this because interface change is not their >> real concern. > > Looks like a good idea. There is an efficiency hit from the above in > some situations, but at least it prevents code from breaking, so unless > there's some drawback I'm not currently spotting, it's better than > nothing and I'd endorse adding such a wrapper. 2to3 should show some > kind of diagnostic and maybe put a comment into the output code, > when it does that particular transformation, since most of the > time there's probably a better way to write the key function. rewriting cmp_to_key in C is underway http://bugs.python.org/issue11707 -- Terry Jan Reedy