[Python-Dev] Deprecating float.is_integer()
tim.peters at gmail.com
Fri Mar 23 01:21:03 EDT 2018
[Kirill Balunov <kirillbalunov at gmail.com>]
>.... In spite of the fact that the pronouncement has
> already been made, there may still be an opportunity to influence this
That's not really how this works. Guido has been doing this for
decades, and when he Pronounces he's done with it :-)
> I do not think that this is only a matter of choice, how this
> functionality will be accessed through a method or function, in fact these
> highly specialized methods heavily pollute the API
"Heavily"? Seems oversold.
> and open the door for persistent questions.
That's a door that can never be closed, no matter what.
> Given the frequency and activity of using this
> `.is_integer` method the deprecation of this method is unlikely to greatly
> affect someone. (for `as_integer_ratio` I think the bar is higher).
> Summarizing this thread it seems to me that with deprecation of `is_integer`
> method and with addition of `is_integer` function in math module will make
> everyone happy:
Not at all, but that's already been explained. Deprecation is
_serous_ business: it's not only the presumably relative handful of
direct users who are directly annoyed, but any number of worldwide web
pages, blogs, books, papers, slides, handouts, message boards ... that
so much as mentioned the now-deprecated feature. The language
implementation is the tiniest part of what's affected, yet is the
_only_ part we (Python developers) can repair.
Deprecation really requires that something is a security hole that
can't be repaired, impossible to make work as intended, approximately
senseless, or is superseded by a new way to accomplish a thing that's
near-universally agreed to be vastly superior. Maybe others?
Regardless, they're all "really big deals".
The "harm" done by keeping these methods seems approximately
insignificant. Serhiy certainly found examples where uses made no
good sense, but that's _common_ among floating-point features. For
example, here's a near-useless implementation of Newton's method for
computing square roots:
guess = x / 2.0
while guess ** 2 != x:
guess = (guess + x / guess) / 2.0
And here I'll use it:
Works great! Ship it :-)
Oops. It just sits there, consuming cycles.
That's because there is no IEEE double x such that x*x == 25.1. While
that's not at all obvious, it's true. Some people really have argued
to deprecate (in)equality testing of floats because of "things like
that", but that's fundamentally nuts. We may as well remove floats
In short, that an fp feature can be misused, and _is_ misused, is no
argument for deprecating it. If it can _only_ be misused, that's
different, but that doesn't apply to is_integer.
That someone - or even almost everyone - is merely annoyed by seeing
an API they have no personal use for doesn't get close to "really big
deal". The time to stop it was before it was added.
> 5. Make everyone happy and stop this thread :)
This thread ended before you replied to it - I'm just a ghost haunting
its graveyard to keep you from feeling ignored -)
More information about the Python-Dev