-
-
Notifications
You must be signed in to change notification settings - Fork 31.1k
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bpo-41870: Avoid the test when nargs=0 #22462
Conversation
return NULL; | ||
if (ok < 0) { | ||
return NULL; | ||
} | ||
} | ||
return PyBool_FromLong(ok); |
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.
I assume it won't make a difference because PyBool_FromLong
will be likely smashed (inlined 😉 ) by the compiler, but can you check if there is any improvement in making the branch yourself here?
Basically changing the PyBool_FromLong(ok)
to a conditional with Py_RETURN_TRUE
and Py_RETURN_FALSE
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.
@pablogsal
I checked it locally and there was no improvement. :)
I will merge this PR without changing ;)
Thank you for the review!
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.
@pablogsal If you want to ensure that a function is inlined, I suggest to add a new variant of PyBool_FromLong() which is delcared as a static inline function.
@corona10: Perfect, thanks! |
https://bugs.python.org/issue41870