summaryrefslogtreecommitdiffstats
path: root/Lib/numbers.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2008-06-17 17:38:02 (GMT)
committerGuido van Rossum <guido@python.org>2008-06-17 17:38:02 (GMT)
commit21a45e1bea1149a30d986af0e7df67a267621d7f (patch)
treef7e9f5545775465eda13c2590e5c2522e32d9603 /Lib/numbers.py
parent9828b7ea08e43dfd9d27b5898c4c551771c04db1 (diff)
downloadcpython-21a45e1bea1149a30d986af0e7df67a267621d7f.zip
cpython-21a45e1bea1149a30d986af0e7df67a267621d7f.tar.gz
cpython-21a45e1bea1149a30d986af0e7df67a267621d7f.tar.bz2
Roll back Raymond's -r64098 while we think of something better.
(See issue 3056 -- we're close to a resolution but need unittests.)
Diffstat (limited to 'Lib/numbers.py')
-rw-r--r--Lib/numbers.py67
1 files changed, 50 insertions, 17 deletions
diff --git a/Lib/numbers.py b/Lib/numbers.py
index 972fe1f..38240d6 100644
--- a/Lib/numbers.py
+++ b/Lib/numbers.py
@@ -283,54 +283,87 @@ class Rational(Real):
class Integral(Rational):
- """Integral adds a conversion to int and the bit-string operations."""
+ """Integral adds a conversion to long and the bit-string operations."""
@abstractmethod
- def __int__(self):
- """int(self)"""
+ def __long__(self):
+ """long(self)"""
raise NotImplementedError
def __index__(self):
"""index(self)"""
- return int(self)
+ return long(self)
+ @abstractmethod
+ def __pow__(self, exponent, modulus=None):
+ """self ** exponent % modulus, but maybe faster.
+
+ Accept the modulus argument if you want to support the
+ 3-argument version of pow(). Raise a TypeError if exponent < 0
+ or any argument isn't Integral. Otherwise, just implement the
+ 2-argument version described in Complex.
+ """
+ raise NotImplementedError
+
+ @abstractmethod
def __lshift__(self, other):
- return int(self) << int(other)
+ """self << other"""
+ raise NotImplementedError
+ @abstractmethod
def __rlshift__(self, other):
- return int(other) << int(self)
+ """other << self"""
+ raise NotImplementedError
+ @abstractmethod
def __rshift__(self, other):
- return int(self) >> int(other)
+ """self >> other"""
+ raise NotImplementedError
+ @abstractmethod
def __rrshift__(self, other):
- return int(other) >> int(self)
+ """other >> self"""
+ raise NotImplementedError
+ @abstractmethod
def __and__(self, other):
- return int(self) & int(other)
+ """self & other"""
+ raise NotImplementedError
+ @abstractmethod
def __rand__(self, other):
- return int(other) & int(self)
+ """other & self"""
+ raise NotImplementedError
+ @abstractmethod
def __xor__(self, other):
- return int(self) ^ int(other)
+ """self ^ other"""
+ raise NotImplementedError
+ @abstractmethod
def __rxor__(self, other):
- return int(other) ^ int(self)
+ """other ^ self"""
+ raise NotImplementedError
+ @abstractmethod
def __or__(self, other):
- return int(self) | int(other)
+ """self | other"""
+ raise NotImplementedError
+ @abstractmethod
def __ror__(self, other):
- return int(other) | int(self)
+ """other | self"""
+ raise NotImplementedError
+ @abstractmethod
def __invert__(self):
- return ~int(self)
+ """~self"""
+ raise NotImplementedError
# Concrete implementations of Rational and Real abstract methods.
def __float__(self):
- """float(self) == float(int(self))"""
- return float(int(self))
+ """float(self) == float(long(self))"""
+ return float(long(self))
@property
def numerator(self):