Python's simplicity philosophy

David Eppstein eppstein at ics.uci.edu
Mon Nov 17 13:51:29 EST 2003


In article <7xislikga7.fsf at ruckus.brouhaha.com>,
 Paul Rubin <http://phr.cx@NOSPAM.invalid> wrote:

> I generally haven't found stability to be important.  When I've cared
> about doing something other than sorting (possibly unstably) on some
> obvious key, I've generally needed some kind of DSU.  Just sorting
> stably wouldn't be enough.  If I'm using DSU anyway, then getting
> stability is trivial if I happen to need it.

If you're doing the DSU by hand, getting stability is not so hard.
But it's not obvious how to do it with the new key= sort argument for 
simplifying DSU.  So there was a long discussion on python-dev about how 
maybe sort needed yet another keyword argument on top of key= for 
specifying that the DSU should include the item positions and be stable; 
but this seemed redundant and overcomplicated given that both current 
Python sorts are already stable.  So Guido ended the discussion by 
declaring that sorts would remain stable, hence no extra keyword 
argument is necessary.

Since DSU is now built in to the sort mechanism anyway, if you're 
rolling your own sort to match that mechanism you shouldn't find it 
difficult to include the positions on top of the other DSU you already 
have to do.

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




More information about the Python-list mailing list