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
Remove dead code in _PyDict_GetItemHint #95948
Conversation
_PyDict_GetItemHint was an optimization that was subsequently made redundant. So let's remove the dead code. I am not removing _PyDict_GetItemHint completely here, because as far as I can tell it performs a different combination of error handling steps than the other ways to get items from a dict.
24edced
to
576a396
Compare
Python/specialize.c
Outdated
_PyDict_GetItemHint(dict, name, -1, &value); | ||
if (hint != (uint16_t)hint) { | ||
Py_ssize_t index = | ||
_PyDict_GetItemSpecialize(dict, name, &value); |
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.
You forgot this one
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.
Thanks for catching that! I was trying to be too quick.
I'm glad we have automated tests.
For future reference, if you force push then the reviewer has to re-review the whole PR. |
It has a leading underscore, so in theory, we are free to remove it. |
The function is not used by Cython. |
Noted. Sorry. I left the commit that you had already seen alone, and only force-pushed an amendment to the new commit. I had assumed github would be smart enough to do the Right Thing. I guess it's not. Thanks for pointing that out! |
Thanks @matthiasgoergens |
Thank you for the quick review, and patience with me forgetting one rename! I'm just getting started with contributing. |
_PyDict_GetItemHint
was an optimization that was subsequently made redundant.So let's remove the dead code.
I am not removing
_PyDict_GetItemHint
completely here, because as far as I can tell it performs a different combination of error handling steps than the other ways to get items from a dict, and I don't feel confident rewriting the code inPython/specialize.c
to work with the different assumptions around error handling.So I am sticking with removing just the dead code, and a rename of the function (so that people get a proper error message when they are trying to still use the old version of
_PyDict_GetItemHint
).If a reviewer has a hint for how to rewrite
Python/specialize.c
to use egPyDict_GetItemWithError
orPyDict_GetItem
, I'd be more than happy to rewrite the PR. Thanks!