[Python-checkins] r64099 - peps/trunk/pep-3141.txt

raymond.hettinger python-checkins at python.org
Wed Jun 11 02:26:20 CEST 2008


Author: raymond.hettinger
Date: Wed Jun 11 02:26:20 2008
New Revision: 64099

Log:
Update PEP to match the mini-pep for simplifying Intergal.

Modified:
   peps/trunk/pep-3141.txt

Modified: peps/trunk/pep-3141.txt
==============================================================================
--- peps/trunk/pep-3141.txt	(original)
+++ peps/trunk/pep-3141.txt	Wed Jun 11 02:26:20 2008
@@ -319,76 +319,52 @@
             """__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 __rlshift__(self, other):
-            raise NotImplementedError
+            return int(other) << int(self)
 
-        @abstractmethod
         def __rshift__(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
 
 


More information about the Python-checkins mailing list