[Python-Dev] Re: other "magic strings" issues

David Eppstein eppstein at ics.uci.edu
Wed Nov 12 12:02:14 EST 2003


In article <2mr80du5br.fsf at starship.python.net>,
 Michael Hudson <mwh at python.net> wrote:

> David Eppstein <eppstein at ics.uci.edu> writes:
> 
> > Ok, it sounds like I am stuck with PyObjC's 
> > NSString.localizedCaseInsensitiveCompare_, since Python's built-in 
> > cmp(unicode,unicode) sucks and locale doesn't provide an alternative.
> 
> "sucks" is too strong.  Maybe there should be better collation support
> but I don't think we should change the default comparison to do it.

Let me be more specific.  Since we have such useful hashing-based 
dictionary data structures in Python, we don't often need cmp for 
binary search trees, so the main reason for comparing unicodes (as far 
as I can tell) is to put them in a logical order for displaying to 
humans.  cmp(unicode,unicode) does a very bad job of this, whenever 
there are non-ascii characters involved.  Its existence tricks you into 
thinking Python has a useful unicode comparison function when it 
doesn't.

-- 
David Eppstein                      http://www.ics.uci.edu/~eppstein/
Univ. of California, Irvine, School of Information & Computer Science




More information about the Python-Dev mailing list