From 054ae8d31906d0b4434aac9a598816869d77c4aa Mon Sep 17 00:00:00 2001 From: Raymond Hettinger Date: Wed, 11 Jun 2008 00:26:20 +0000 Subject: [PATCH] Update PEP to match the mini-pep for simplifying Intergal. --- pep-3141.txt | 52 ++++++++++++++-------------------------------------- 1 file changed, 14 insertions(+), 38 deletions(-) diff --git a/pep-3141.txt b/pep-3141.txt index 697ae99f8..ba5a31fc0 100644 --- a/pep-3141.txt +++ b/pep-3141.txt @@ -319,76 +319,52 @@ And finally integers:: """__index__() exists because float has __int__().""" return int(self) - @abstractmethod - def __pow__(self, exponent, modulus=None): - """self ** exponent % modulus, but maybe faster. - - Implement this if you want to support the 3-argument - version of pow(). Otherwise, just implement the 2-argument - version described in Complex. If modulus is None, this - should behave as the 2-argument version; otherwise, raise - a TypeError if exponent < 0 or any argument isn't - Integral. - """ - raise NotImplementedError - - @abstractmethod def __lshift__(self, other): - """i<>j returns i // 2**j.""" - raise NotImplementedError + return int(self) >> int(other) - @abstractmethod def __rrshift__(self, other): - raise NotImplementedError + return int(other) >> int(self) - @abstractmethod def __and__(self, other): - raise NotImplementedError + return int(self) & int(other) - @abstractmethod def __rand__(self, other): - raise NotImplementedError + return int(other) & int(self) - @abstractmethod def __xor__(self, other): - raise NotImplementedError + return int(self) ^ int(other) - @abstractmethod def __rxor__(self, other): - raise NotImplementedError + return int(other) ^ int(self) - @abstractmethod def __or__(self, other): - raise NotImplementedError + return int(self) | int(other) - @abstractmethod def __ror__(self, other): - raise NotImplementedError + return int(other) | int(self) - @abstractmethod def __invert__(self): - raise NotImplementedError + return ~int(self) # Concrete implementations of Rational and Real abstract methods. - def __float__(self): + """float(self) == float(int(self))""" return float(int(self)) @property def numerator(self): + """Integers are their own numerators.""" return +self @property def denominator(self): + """Integers have a denominator of 1.""" return 1