Skip to content
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

Merged
merged 1 commit into from Oct 1, 2020

Conversation

corona10
Copy link
Member

@corona10 corona10 commented Sep 30, 2020

return NULL;
if (ok < 0) {
return NULL;
}
}
return PyBool_FromLong(ok);
Copy link
Member

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

Copy link
Member Author

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!

Copy link
Member

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 corona10 merged commit fa7ce08 into python:master Oct 1, 2020
@vstinner
Copy link
Member

vstinner commented Oct 1, 2020

@corona10: Perfect, thanks!

xzy3 pushed a commit to xzy3/cpython that referenced this pull request Oct 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants