-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
bpo-30509: Optimize and clean up calling type slots. #1861
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
base: main
Are you sure you want to change the base?
Conversation
@serhiy-storchaka, thanks for your PR! By analyzing the history of the files in this pull request, we identified @tim-one, @larryhastings and @benjaminp to be potential reviewers. |
Objects/typeobject.c
Outdated
*/ | ||
|
||
static PyObject * | ||
lookup_maybe(PyObject *self, _Py_Identifier *attrid) | ||
PyObject * |
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.
Why do you make this function public? (you removed static)
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.
lookup_maybe()
was used only in _PyObject_LookupSpecial()
and set_names()
. The latter is not performance critical and can use _PyObject_LookupSpecial()
instead of lookup_maybe()
. Thus I just inlined lookup_maybe()
in the single place where it is used, in _PyObject_LookupSpecial()
.
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.
Oh, I see. I didn't notice that _PyObject_LookupSpecial() already exist in the current code. I checked, it's called from various places in CPython :-) Your change makes sense ;-)
2625c29
to
dac5ba7
Compare
Objects/typeobject.c
Outdated
@@ -6209,6 +6225,7 @@ slot_tp_hash(PyObject *self) | |||
} | |||
|
|||
if (func == NULL) { | |||
PyErr_Clear(); |
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 don't understand why PyErr_Clear() is needed with your change.
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.
Actually it is not needed.
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.
While I am not 100% convinced that the change makes Python faster, the change itself now LGTM thanks to the first cleanup commit. I let you decide to merge it or not ;-) (my vote is +0)
@serhiy-storchaka were you interested in revisiting this to see if it should be merged or not? Thanks! |
This PR is stale because it has been open for 30 days with no activity. |
This PR is stale because it has been open for 30 days with no activity. |
This PR is stale because it has been open for 30 days with no activity. |
This PR is stale because it has been open for 30 days with no activity. |
It would be interesting to rebase this PR on the main branch. |
This PR is stale because it has been open for 30 days with no activity. |
No description provided.