[Python-Dev] partition() (was: Remove str.find in 3.0?)

Raymond Hettinger raymond.hettinger at verizon.net
Tue Aug 30 03:26:35 CEST 2005


[Delaney, Timothy (Tim)]
> +1
> 
> This is very useful behaviour IMO.

Thanks.  It seems to be getting +1s all around.



> Have the precise return values of partition() been defined?
 . . .
> IMO the most useful (and intuitive) behaviour is to return strings in
> all cases.

Yes, there is a precise spec and yes it always returns three strings.  

Movitation and spec:
http://mail.python.org/pipermail/python-dev/2005-August/055764.html

Pure python implementation, sample invocations, and tests:
http://mail.python.org/pipermail/python-dev/2005-August/055764.html



> My major issue is with the names - partition() doesn't sound right to
> me. 

FWIW, I am VERY happy with the name partition().  It has a long and
delightful history in conjunction with the quicksort algorithm where it
does something very similar to what we're doing here:  partitioning data
into three groups (left,center,right) with a small center element
(called a pivot in the quicksort context and called a separator in our
string parsing context).  This name has enjoyed great descriptive
success in communicating that the total data size is unchanged and that
the parts can be recombined to the whole.  IOW, it is exactly the right
word.  I won't part with it easily.

    http://www.google.com/search?q=quicksort+partition


Raymond



More information about the Python-Dev mailing list