Message396864
The background is an implementation of __pow__ for a fixed-point decimal number:
SupportsIntOrFloat = Union[SupportsInt, SupportsFloat]
def __pow__(self, other: SupportsIntOrFloat, mod: Any = None) -> Complex:
if isinstance(other, SupportsInt):
exp = int(other)
if exp == other:
... handle integer exponent
if isinstance(other, SupportsFloat):
# fractional exponent => fallback to float
return float(self) ** float(other)
return NotImplemented
I came across SupportsInt and SupportsFloat, because they are used in typeshed as param types for int and float. |
|
| Date |
User |
Action |
Args |
| 2021-07-02 13:36:09 | mamrhein | set | recipients:
+ mamrhein, mark.dickinson, josh.r |
| 2021-07-02 13:36:09 | mamrhein | set | messageid: <1625232969.57.0.273722007446.issue44547@roundup.psfhosted.org> |
| 2021-07-02 13:36:09 | mamrhein | link | issue44547 messages |
| 2021-07-02 13:36:09 | mamrhein | create | |
|