Guido rethinking removal of cmp from sort method

harrismh777 harrismh777 at charter.net
Thu Mar 31 02:34:17 EDT 2011


Antoon Pardon wrote:
> On Sun, Mar 13, 2011 at 12:59:55PM +0000, Steven D'Aprano wrote:
>> The removal of cmp from the sort method of lists is probably the most
>> disliked change in Python 3. On the python-dev mailing list at the
>> moment, Guido is considering whether or not it was a mistake.
>>
>> If anyone has any use-cases for sorting with a comparison function that
>> either can't be written using a key function, or that perform really
>> badly when done so, this would be a good time to speak up.
>
> How about a list of tuples where you want them sorted first item in ascending
> order en second item in descending order.
>
Greetings,

     Not sure here, but thought you folks might want to have another 
viewpoint from someone who is maybe not so close to the trees as to be 
able to comment effectively on the forest.

     Many of you (Guido included) have lost significant sight of a 
critical object oriented philosophical pillar (but not all of you, thank 
goodness). To cut right to the heart of it--- NEVER change an advertised 
interface. Change the implementation to your little hearts desire, but 
never alter an advertised interface (code is based on it, books are 
based on it, tutorials are based on it, college comp sci courses are 
based on it... etc). If cmp parm is utilized and is helpful or perceived 
as useful and existing code requires it then for crying out loud leave 
it alone. I think your overall worship of Guido as Python King has left 
many of you with nobbled thinking.

     On the other hand, this debate and constant bickering is a serious 
rehash of an ancient discussion without any new points--- irritating. 
Take a look at issue 1771  http://bugs.python.org/issue1771 
particularly msg #s 95975 and 95982....  but no, read the whole 
thing.... it is very clear that Guido wants to restructure the python 
language for consistency and elegance (and who can blame him?). He makes 
some very good arguments for the justification of removing the cmp 
keyword from list.sort() and builtin.sorted()/   but, that is not the 
point... he is breaking a fundamental law of object oriented 
programming... don't break and advertised interface (particularly if it 
is useful and people are actually making use of it!).
     This is insane folks.

     Python is one of the most elegant OO languages to gain popular 
appeal and wide-spread use. This sad broken move from 2.x to 3.x has the 
potential of ruining the language for everyone. Many of us dropped JAVA 
(compile once debug everywhere) because it is complicated, a pita to 
use, slow, and actually doesn't port too well on any platform... and 
here we go again with python. How do the developers of python ever 
expect folks to be able to make use of the language into the future when 
every time we turn around the interface is broken or being debated in 
flux?  Many of us want to use the new 3.2+ version, but no one is going 
to ship it pre-installed (probably for many years) because of this 
issue. There is no way to easily migrate, nor backport, and everyone is 
going to be forced to develop code (and have to maintain code) on two 
distinct branches (for many years to come). I suspect that people are 
just going to stick with back versions for a long time.
     We need to get a grip on this, people.

     Guido does not need a use case; he just needs to restore the 
interface that everyone expects. Put up a message to start to use key= 
instead, and plan deprecation for something like five years out... this 
just seems like such a no-brainer to me. But then, maybe its just that 
I'm too inexperienced to know any better.  <sigh>

     In the mean time... I'm playing around with 3.2 and really liking 
it... hoping that the world will actually be using it someday.

Kind regards,
m harris




More information about the Python-list mailing list