Open
Description
Bug report
Bug description:
The math.log
function has a special path for integers that only works for the builtin int
type:
Lines 2220 to 2223 in ac61d58
That means that it does not work for 3rd party integer types e.g.:
In [9]: n = gmpy2.mpz(10)**1000
In [10]: math.log(int(n))
Out[10]: 2302.585092994045
In [12]: math.log(operator.index(n))
Out[12]: 2302.585092994045
In [11]: math.log(n)
---------------------------------------------------------------------------
OverflowError Traceback (most recent call last)
Cell In[11], line 1
----> 1 math.log(n)
OverflowError: 'mpz' too large to convert to float
Maybe if there is a special integer handling path in math.log
it should check for __index__
before __float__
.
Related gh-106502 is about math.log
with Decimal
.
CPython versions tested on:
3.13
Operating systems tested on:
No response