summaryrefslogtreecommitdiffstats
path: root/Lib/numbers.py
diff options
context:
space:
mode:
authorRaymond Hettinger <rhettinger@users.noreply.github.com>2020-10-07 23:43:44 (GMT)
committerGitHub <noreply@github.com>2020-10-07 23:43:44 (GMT)
commit4e0ce820586e93cfcefb16c2a3df8eaefc54cbca (patch)
tree62e95d644abcbc04dd6baedc9b3f44f42d4d974f /Lib/numbers.py
parent4f3c25043d651a13c41cffcee703f7d5cb677cc7 (diff)
downloadcpython-4e0ce820586e93cfcefb16c2a3df8eaefc54cbca.zip
cpython-4e0ce820586e93cfcefb16c2a3df8eaefc54cbca.tar.gz
cpython-4e0ce820586e93cfcefb16c2a3df8eaefc54cbca.tar.bz2
Revert "bpo-26680: Incorporate is_integer in all built-in and standard library numeric types (GH-6121)" (GH-22584)
This reverts commit 58a7da9e125422323f79c4ee95ac5549989d8162.
Diffstat (limited to 'Lib/numbers.py')
-rw-r--r--Lib/numbers.py21
1 files changed, 1 insertions, 20 deletions
diff --git a/Lib/numbers.py b/Lib/numbers.py
index 0634f62..ed815ef 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)