diff options
author | Raymond Hettinger <rhettinger@users.noreply.github.com> | 2020-10-06 22:13:34 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-06 22:13:34 -0700 |
commit | 1cc1a8f11a769c42a162229f3e1fb3a0fa74d4b9 (patch) | |
tree | e739e0905d3b06a1ebbbfca18fbf324989b99ad4 /Lib/numbers.py | |
parent | 044a1048ca93d466965afc027b91a5a9eb9ce23c (diff) | |
download | cpython-git-revert-6121-is_integer.tar.gz |
Revert "bpo-26680: Incorporate is_integer in all built-in and standard library numeric types (GH-6121)"revert-6121-is_integer
This reverts commit 58a7da9e125422323f79c4ee95ac5549989d8162.
Diffstat (limited to 'Lib/numbers.py')
-rw-r--r-- | Lib/numbers.py | 21 |
1 files changed, 1 insertions, 20 deletions
diff --git a/Lib/numbers.py b/Lib/numbers.py index 0634f62ff1..ed815ef41e 100644 --- a/Lib/numbers.py +++ b/Lib/numbers.py @@ -148,7 +148,7 @@ class Real(Complex): """To Complex, Real adds the operations that work on real numbers. In short, those are: a conversion to float, trunc(), divmod, - is_integer, %, <, <=, >, and >=. + %, <, <=, >, and >=. Real also provides defaults for the derived operations. """ @@ -242,17 +242,6 @@ class Real(Complex): """self <= other""" raise NotImplementedError - def is_integer(self): - """Return True if the Real is integral; otherwise return False. - - This default implementation can be overridden in subclasses - for performance reasons or to deal with values such as NaN, - which would otherwise cause an exception to be raised. - """ - # Although __int__ is not defined at this level, the int - # constructor falls back to __trunc__, which we do have. - return self == int(self) - # Concrete implementations of Complex abstract methods. def __complex__(self): """complex(self) == complex(float(self), 0)""" @@ -301,10 +290,6 @@ class Rational(Real): """ return self.numerator / self.denominator - def is_integer(self): - """Return True if the Rational is integral; otherwise return False.""" - return self.denominator == 1 - class Integral(Rational): """Integral adds a conversion to int and the bit-string operations.""" @@ -401,8 +386,4 @@ class Integral(Rational): """Integers have a denominator of 1.""" return 1 - def is_integer(self): - """Return True; all Integrals represent an integral value.""" - return True - Integral.register(int) |