A use for integer quotients

Guido van Rossum guido at python.org
Wed Jul 25 06:41:49 CEST 2001


"John W. Baxter" <jwbaxter at spamcop.com> writes:

> In article <cpzo9veuml.fsf at cj20424-a.reston1.va.home.com>, Guido van
> Rossum <guido at python.org> wrote:
> 
> > Of course, I'm well aware of the issues around maintaining old code.
> > We will have to carry around "from __future__ import division" for a
> > loooooong time.  Python 2.2 is the first opportunity to introduce it,
> > so let's not be shy.
> 
> This is encouraging and discouraging:
> 
> Encouraging in that it suggests strongly that 2.3 isn't the target;
> discouraging in that it gives running code even longer to sit in the
> basement with people who know it moving on before it breaks.
> 
> It's also discouraging because it means the change does seem to be on
> the way, with argument useless.

Well, so far the only arguments I've heard come down to

(1) int/int *ought* to return an int;

(2) it breaks too much code to change now.

IMO, argument (1) is misguided.  I've heard all the variations many
times by now and none are convincing to me; they are either wrong,
like "that's how mathematicians define it" or "that's how all
right-thinking programming languages define it", or they miss the
point, like "it's easy to explain to newbies that int/int returns
int".

Attempts to convince the proponents of (1) seem useless -- otherwise
this thread wouldn't last so long -- so I won't repeat the
explanation.  Let me add that it has nothing to do with teaching
Python to newbies -- the problem is a fundamental design bug.
(Ironically, it dates back to the day, probably in 1991, that Tim
Peters convinced me that int+float should automatically coerce the int
to a float rather than raise a type error; this embedded the integers
in the floats, and we should have realized then that int division
should therefore also be embedded in the floats.)

Argument (2) is very real, therefore I am trying to address it with
all my might.  See my other posts.

--Guido van Rossum (home page: http://www.python.org/~guido/)



More information about the Python-list mailing list