Version compatibility in division
tanzer at swing.co.at
Fri Jul 27 10:55:37 CEST 2001
"Tim Peters" <tim.one at home.com> wrote:
> [David Bolen]
> > ...
> > Then again, the bigger problem with int() is the potential for
> > rounding that is, at least theoretically, permitted by the
> > implementation, although as someone else pointed out, it's not clear
> > that any C libraries actually do that.
> Guido suggested that "someone" (certainly me) change Python's implementation
> so that int() and long() always truncate, regardless of what the platform C
> happens to do. I can do that, no problem.
> There are no known platforms on which that will make a lick of difference,
> except to make Python run slower. But that doesn't mean no such platforms
> exist. And making a particular Python operation run slower can change the
> behavior of, e.g., threaded apps. It's also the case that platforms
> certainly vary even now in how int(infinity) and int(NaN) behave (since C89
> is silent on those cases), and that they may suffer some different
> accidental behavior in these cases after the change.
Judging by your many other posts, I think you'll be able to avoid any
performance hit for all the platforms where C does the right thing
I don't see how changing previously undefined behavior to
platform-indpendent behavior makes you worry, though. As far as I
understood one of your previous posts about this topic, moving to a
C99(?) compiler would have the same effect anyway.
For sure you aren't planning on introducing `from __future__ import
C99_semantics` for when Python migrates to one of these new-fangled
> So is this a change we should be frightened of? Do we need a
> from __future__ import int_and_long_guaranteed_to_truncate
> statement to enable it?
> I think that would be absurd, but from an implementer's point of view it's
> the plain truth that no change is without consequences.
So it is.
Christian Tanzer tanzer at swing.co.at
Glasauergasse 32 Tel: +43 1 876 62 36
A-1130 Vienna, Austria Fax: +43 1 877 66 92
More information about the Python-list