[Python-Dev] Re: PEP 326: A Case for All
Phillip J. Eby
pje at telecommunity.com
Sun Jan 4 15:57:48 EST 2004
At 12:00 PM 1/4/04 -0800, Josiah Carlson wrote:
>Further uses of All will be left as an exercise to whomever wants to use
>it.
Um, then why don't those people just write their own 'All'? It's not like
they all need to be using the same definition of 'All', so why put it in
Python?
The "Motivation" section of PEP 326 does not answer this
question. Although it claims "hundreds of algorithms", it demonstrates
only *one*: finding the minimum of a sequence.
The example shows three versions of finding a minimum of a sequence, to
show that it's easier with 'All'. But that's a straw man argument: the
*easiest* way to get the desired behavior is just to use 'min(seq)' and not
write any new functions at all!
So, essentially, the "Motivation" section might as well not be in the PEP,
because it provides no actual motivation at all. You need to find a better
algorithm to cover.
And don't bother using "find the pair x,y from a sequence of pairs where
'x' is the lowest item" as a substitute, because again the answer is
'min(seq)'. And even if you say, "yes but we don't want 'y' to be
compared", there's always:
def min_key(pairs):
minX, chosenY = pairs[0]
for x,y in pairs[1:]
if x<minX:
minX, chosenY = x,y
return minX, chosenY
or, if you prefer using iterators to slicing:
def min_key(pairs):
pairs = iter(pairs)
minX, chosenY = pairs.next()
for x,y in pairs
if x<minX:
minX, chosenY = x,y
return minX, chosenY
So, please pick some examples that aren't based on finding minimums, and
that also illustrate why it's important that Python itself include this
concept. Can you show why it's a bad thing for people to implement their
own infinity-like type(s)? In what areas does the standard library show a
need for such an object? And so on.
Without more motivation for the proposal, you're likely to see continued
opposition to the PEP.
More information about the Python-Dev
mailing list