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

gh-81313: Add the imath module#133909

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
serhiy-storchaka wants to merge7 commits intopython:main
base:main
Choose a base branch
Loading
fromserhiy-storchaka:imath3

Conversation

serhiy-storchaka
Copy link
Member

@serhiy-storchakaserhiy-storchaka commentedMay 11, 2025
edited by github-actionsbot
Loading

@serhiy-storchaka
Copy link
MemberAuthor

This is a further development of#13741.

@vstinner
Copy link
Member

A PEP is being written for this module:skirpichev/peps#8

@vstinner
Copy link
Member

cc@skirpichev

Copy link
Contributor

@itamaroitamaro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

is this PR open (not draft) because there's an intent to merge it? (while a PEP is still being drafted?)

I left a comment on the PEP draft about naming (and conflict with an existing, maintained, Imath project)

corona10 reacted with thumbs up emoji
Copy link
Contributor

@skirpichevskirpichev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Thanks, I'll link to this as an implementation.

Comment on lines +52 to +59
.. function:: ilog2(n)

Return the integer base 2 logarithm of the positive integer *n*. This is the
floor of the exact base 2 logarithm root of *n*, or equivalently the
greatest integer *k* such that
2\ :sup:`k` |nbsp| ≤ |nbsp| *n* |nbsp| < |nbsp| 2\ :sup:`k+1`.

It is equivalent to ``n.bit_length() - 1`` for positive *n*.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This function seems redundant.

Also, I think it's better to first just plain moving of functions. No new features.

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I'll remove it if you with.

Initially I planned to add more functions (in addition to new functionsisqrt(),perm() andcomb()).ilog2() is similar toint.bit_length(), but uses__index__(). After our discussion aboutmath.log() I think that there is also a use case for 2-argumentilog() (to determine the number of decimal digits in a number, for example). But this is a different issue.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

As any addition to the stdlib, I think it deserves at least own issue. Lets just settle up the new module and move things properly.

Comment on lines +12 to +13
These functions accept integers and objects that implement the
:meth:`~object.__index__` method which is used to convert the object to an integer
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

In the same way we could simplify now description of argument processing in the math module. Except for a special snowflake "log" - all use PyFloat_AsDouble(). (Well, few functions also try special dunder methods.)

Though, probably it's for following prs.

@corona10
Copy link
Member

I think that the PEP should be written before we handle this issue.

@skirpichev
Copy link
Contributor

I think that the PEP should be written before we handle this issue.

python/peps#4422

@skirpichevskirpichev self-requested a reviewMay 13, 2025 12:39
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@itamaroitamaroitamaro requested changes

@erlend-aaslanderlend-aaslandAwaiting requested review from erlend-aaslanderlend-aasland is a code owner

@corona10corona10Awaiting requested review from corona10corona10 is a code owner

@skirpichevskirpichevAwaiting requested review from skirpichev

Assignees
No one assigned
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

5 participants
@serhiy-storchaka@vstinner@corona10@skirpichev@itamaro

[8]ページ先頭

©2009-2025 Movatter.jp