PEP0238 lament

Terry Reedy tjreedy at home.com
Mon Jul 23 00:22:32 EDT 2001


> It [int/int->int] can be useful for many things; that's not at
issue,

Actually, it did seem to be an issue when a couple of people seemed to
suggest that some of us were mentally unbalanced in thinking that
integer quotients are the right and useful result for int/int.

>and nobody has ever proposed taking away the ability to get an
integer result;
> the issue is how  to spell that.

And that issue was *not* spelled out in the PEP.

Actually, as I mention in my article today 'A use for integer
quotients', I thought that one version of the proposal *was* to take
away the current spelling without providing any replacement.  That is
what I argued most strenously against.

I know that one version of the proposal was to provide an
*unacceptible* (to me) replacement -- div(i,j).  Guido appeared to
maybe even favor it until I pointed out that an infix replacement
would make fixing current code *much* easier.

This gets to the issue of what is a proper PEP.  Simply saying 'I
don't like the current situation; lets replace it with something' is
not, in my opinion.  The only thing definite that I remember from
reading PEP 238 was to change the result of int/int to float.  Then
maybe add div() [awful], div [possible], // [best in my opinion],
something else [???], or, at least by implication, nothing
[horrendous].  It is hard compare something definite (the current
situation, whatever it is) to a nebulosity, especially when the range
of alternatives floating around the nebula range from horrendous to
maybe ok.

If 238 had been written originally something like the following (which
it now is), I would have argued *much* less.

Situation: Python '/' currently overloads and confounds two arithmetic
operations: whole-number result division and fractional result
division.  This confuses some people.
Proposal: Make '/' consistently mean fractional division and introduce
a new operator '//' for truncated-result division.
Acknowledgement: This semantic replacement is a bit different from
most any previous change to Python.  Extra care will be needed to make
the transition as smooth as possible.

(Just noticed:  http://python.sourceforge.net/peps/pep-0238.html
now proposes a *2 year* int/int warning period starting with 2.3.  It
still needs a stipulation that someone write an intdiv checker to help
automate replacements.)

Terry J. Reedy






More information about the Python-list mailing list