Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

math.log handles int but not 3rd party integer types #120950

Open
Assignees
skirpichevserhiy-storchaka
Labels
extension-modulesC modules in the Modules dirtype-featureA feature request or enhancement
@oscarbenjamin

Description

@oscarbenjamin

Bug report

Bug description:

Themath.log function has a special path for integers that only works for the builtinint type:

loghelper(PyObject*arg,double (*func)(double))
{
/* If it is int, do it ourselves. */
if (PyLong_Check(arg)) {

That means that it does not work for 3rd party integer types e.g.:

In [9]:n=gmpy2.mpz(10)**1000In [10]:math.log(int(n))Out[10]:2302.585092994045In [12]:math.log(operator.index(n))Out[12]:2302.585092994045In [11]:math.log(n)---------------------------------------------------------------------------OverflowErrorTraceback (mostrecentcalllast)CellIn[11],line1---->1math.log(n)OverflowError:'mpz'toolargetoconverttofloat

Maybe if there is a special integer handling path inmath.log it should check for__index__ before__float__.

Relatedgh-106502 is aboutmath.log withDecimal.

CPython versions tested on:

3.13

Operating systems tested on:

No response

Linked PRs

Metadata

Metadata

Labels

extension-modulesC modules in the Modules dirtype-featureA feature request or enhancement

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions


    [8]ページ先頭

    ©2009-2025 Movatter.jp