Update PEP to match the mini-pep for simplifying Intergal.
This commit is contained in:
parent
e078deceb9
commit
054ae8d319
52
pep-3141.txt
52
pep-3141.txt
|
@ -319,76 +319,52 @@ And finally integers::
|
||||||
"""__index__() exists because float has __int__()."""
|
"""__index__() exists because float has __int__()."""
|
||||||
return int(self)
|
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):
|
def __lshift__(self, other):
|
||||||
"""i<<j returns i * 2**j."""
|
return int(self) << int(other)
|
||||||
raise NotImplementedError
|
|
||||||
|
|
||||||
@abstractmethod
|
|
||||||
def __rlshift__(self, other):
|
def __rlshift__(self, other):
|
||||||
raise NotImplementedError
|
return int(other) << int(self)
|
||||||
|
|
||||||
@abstractmethod
|
|
||||||
def __rshift__(self, other):
|
def __rshift__(self, other):
|
||||||
"""i>>j returns i // 2**j."""
|
return int(self) >> int(other)
|
||||||
raise NotImplementedError
|
|
||||||
|
|
||||||
@abstractmethod
|
|
||||||
def __rrshift__(self, other):
|
def __rrshift__(self, other):
|
||||||
raise NotImplementedError
|
return int(other) >> int(self)
|
||||||
|
|
||||||
@abstractmethod
|
|
||||||
def __and__(self, other):
|
def __and__(self, other):
|
||||||
raise NotImplementedError
|
return int(self) & int(other)
|
||||||
|
|
||||||
@abstractmethod
|
|
||||||
def __rand__(self, other):
|
def __rand__(self, other):
|
||||||
raise NotImplementedError
|
return int(other) & int(self)
|
||||||
|
|
||||||
@abstractmethod
|
|
||||||
def __xor__(self, other):
|
def __xor__(self, other):
|
||||||
raise NotImplementedError
|
return int(self) ^ int(other)
|
||||||
|
|
||||||
@abstractmethod
|
|
||||||
def __rxor__(self, other):
|
def __rxor__(self, other):
|
||||||
raise NotImplementedError
|
return int(other) ^ int(self)
|
||||||
|
|
||||||
@abstractmethod
|
|
||||||
def __or__(self, other):
|
def __or__(self, other):
|
||||||
raise NotImplementedError
|
return int(self) | int(other)
|
||||||
|
|
||||||
@abstractmethod
|
|
||||||
def __ror__(self, other):
|
def __ror__(self, other):
|
||||||
raise NotImplementedError
|
return int(other) | int(self)
|
||||||
|
|
||||||
@abstractmethod
|
|
||||||
def __invert__(self):
|
def __invert__(self):
|
||||||
raise NotImplementedError
|
return ~int(self)
|
||||||
|
|
||||||
# Concrete implementations of Rational and Real abstract methods.
|
# Concrete implementations of Rational and Real abstract methods.
|
||||||
|
|
||||||
def __float__(self):
|
def __float__(self):
|
||||||
|
"""float(self) == float(int(self))"""
|
||||||
return float(int(self))
|
return float(int(self))
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def numerator(self):
|
def numerator(self):
|
||||||
|
"""Integers are their own numerators."""
|
||||||
return +self
|
return +self
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def denominator(self):
|
def denominator(self):
|
||||||
|
"""Integers have a denominator of 1."""
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue