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


Groups > comp.lang.python > #2188

Re: Guido rethinking removal of cmp from sort method

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'terry': 0.07; 'url:bugs': 0.07; 'comparisons': 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; 'tracker': 0.09; 'answer,': 0.16; 'arbitrary.': 0.16; 'cmp': 0.16; 'py3k': 0.16; 'pydev': 0.16; 'reedy': 0.16; 'subject:sort': 0.16; 'case.': 0.16; 'tend': 0.16; 'skip:m 30': 0.16; 'input': 0.18; 'functions,': 0.19; 'mapping': 0.19; 'discussion': 0.20; 'jan': 0.22; 'header:In-Reply-To:1': 0.22; 'values': 0.23; 'conflicts': 0.23; 'parameters': 0.26; 'problem': 0.29; 'list': 0.30; 'avoided': 0.31; 'does': 0.31; 'meaning': 0.31; 'anyone': 0.31; 'to:addr:python-list': 0.32; 'minor': 0.33; '(for': 0.33; 'header:X-Complaints-To:1': 0.34; 'there': 0.35; 'print': 0.35; 'header:User-Agent:1': 0.35; 'point': 0.35; 'constant': 0.35; 'list.': 0.35; 'url:python': 0.37; 'bigger': 0.38; 'consistent': 0.38; 'removing': 0.38; 'thread': 0.38; 'url:org': 0.38; 'received:org': 0.38; 'though': 0.38; 'somewhat': 0.39; 'to:addr:python.org': 0.39; 'header:Mime-Version:1': 0.39; 'how': 0.39; 'would': 0.40; 'header:Received:5': 0.40; 'learned': 0.73; 'interested,': 0.75; 'subject:removal': 0.84
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Terry Reedy <tjreedy@udel.edu>
Subject Re: Guido rethinking removal of cmp from sort method
Date Tue, 29 Mar 2011 15:35:40 -0400
References <20110323151426.GB5668@trout.vub.ac.be> <AANLkTi=PTZGVqFTJ17O0xb0O7+mRmVDBsjjckgr5X-L9@mail.gmail.com> <20110324092323.GC5668@trout.vub.ac.be> <AANLkTi=Ux2wRJ8u=myd1jeneR+kZiFhtnwDLHm=GtFtV@mail.gmail.com> <mailman.1207.1300985048.1189.python-list@python.org> <4d8bd8a1$0$29977$c3e8da3$5496439d@news.astraweb.com> <mailman.1231.1301044708.1189.python-list@python.org> <4d8d1203$0$29977$c3e8da3$5496439d@news.astraweb.com> <mailman.1333.1301315748.1189.python-list@python.org> <4d90ac87$0$30000$c3e8da3$5496439d@news.astraweb.com> <20110329084657.GE26597@trout.vub.ac.be> <AANLkTinyEpTVaAjikP8M108ymj=J6LV2styp+Md-siwj@mail.gmail.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 <AANLkTinyEpTVaAjikP8M108ymj=J6LV2styp+Md-siwj@mail.gmail.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 <python-list.python.org>
List-Unsubscribe <http://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 <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1378.1301427355.1189.python-list@python.org> (permalink)
Lines 28
NNTP-Posting-Host 82.94.164.166
X-Trace 1301427355 news.xs4all.nl 81478 [::ffff:82.94.164.166]:41469
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:2188

Show key headers only | View raw


For anyone interested, the tracker discussion on removing cmp is at
http://bugs.python.org/issue1771
There may have been more on the old py3k list and pydev list.

One point made there is that removing cmp= made list.sort consistent 
with all the other comparision functions, 
min/max/nsmallest/nlargest/groupby that only have a key arg. How many 
would really want cmp= added everywhere?

A minor problem problem with cmp is that the mapping between return 
values and input comparisons is somewhat arbitrary. Does -1 mean a<b or 
b<a? (That can be learned and memorized, of course, though I tend to 
forget without constant use).

A bigger problem is that it conflicts with key=. What is the result of
l=[1,3,2]
l.sort(cmp=lambda x,y:y-x, key=lambda x: x)
print l
? (for answer, see http://bugs.python.org/issue11712 )

While that can also be learned, I consider conflicting parameters 
undesireable and better avoided when reasonably possible. So I see this 
thread as a discussion of the meaning of 'reasonably' in this particular 
case.

-- 
Terry Jan Reedy

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


Thread

Re: Guido rethinking removal of cmp from sort method Terry Reedy <tjreedy@udel.edu> - 2011-03-29 15:35 -0400

csiph-web