Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32k
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
gh-132987: Support __index__() in the stat module#133097
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Use it for the mode arguments in filemode(), S_IMODE(), S_ISDIR(), etc.
There was a problem hiding this 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); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
LGTM
c33efa8
intopython:mainUh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Use it for the mode arguments in filemode(), S_IMODE(), S_ISDIR(), etc.