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-132987: Support __index__() in the stat module#133097

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

Conversation

serhiy-storchaka
Copy link
Member

@serhiy-storchakaserhiy-storchaka commentedApr 28, 2025
edited by bedevere-appbot
Loading

Use it for the mode arguments in filemode(), S_IMODE(), S_ISDIR(), etc.

Use it for the mode arguments in filemode(), S_IMODE(), S_ISDIR(), etc.
Copy link
Member

@vstinnervstinner left a comment

Choose a reason for hiding this comment

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

LGTM

value = PyLong_AsUnsignedLong(op);
if ((value == (unsigned long)-1) && PyErr_Occurred())
if (PyLong_Check(op)) {
value = PyLong_AsUnsignedLong(op);
Copy link
Member

Choose a reason for hiding this comment

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

This code path looks like a micro-optimization (to avoid PyNumber_Index). I don't think that it's worth it.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Not only. Many functions likePyLong_AsUnsignedLong() andPyLong_AsUnsignedLongMask(), many setters and converter, only call__index__() if the argument notint. So there would be a subtle behavior difference when the argument is an instance of theint subclass which defines__index__(). And calling__index__() forint subclass adds overhead.

But this is not completely consistent, so this may not make large difference.

Copy link
Member

@vstinnervstinner left a comment

Choose a reason for hiding this comment

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

LGTM

@serhiy-storchakaserhiy-storchaka merged commitc33efa8 intopython:mainApr 29, 2025
49 checks passed
@serhiy-storchakaserhiy-storchaka deleted the stat-unsigned-int-index branchApril 29, 2025 16:25
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@vstinnervstinnervstinner approved these changes

Assignees
No one assigned
Labels
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@serhiy-storchaka@vstinner

[8]ページ先頭

©2009-2025 Movatter.jp