cpython icon indicating copy to clipboard operation
cpython copied to clipboard

Remove dead code in _PyDict_GetItemHint

Open matthiasgoergens opened this issue 3 years ago • 2 comments

_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 in Python/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 eg PyDict_GetItemWithError or PyDict_GetItem, I'd be more than happy to rewrite the PR. Thanks!

matthiasgoergens avatar Aug 13 '22 05:08 matthiasgoergens

For future reference, if you force push then the reviewer has to re-review the whole PR. If you push normally, then the reviewer just needs to check the additional changes. This is a small PR, so it doesn't matter much here.

markshannon avatar Aug 16 '22 09:08 markshannon

Have you checked that Cython doesn't use this API?

It has a leading underscore, so in theory, we are free to remove it. Isn't documented, and there are no tests for it. So we don't even know if works.

@scoder?

methane avatar Aug 16 '22 09:08 methane

The function is not used by Cython.

scoder avatar Aug 18 '22 05:08 scoder

For future reference, if you force push then the reviewer has to re-review the whole PR. If you push normally, then the reviewer just needs to check the additional changes. This is a small PR, so it doesn't matter much here.

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!

matthiasgoergens avatar Aug 18 '22 08:08 matthiasgoergens

Thanks @matthiasgoergens

markshannon avatar Aug 18 '22 09:08 markshannon

Thanks @matthiasgoergens

Thank you for the quick review, and patience with me forgetting one rename!

I'm just getting started with contributing.

matthiasgoergens avatar Aug 18 '22 10:08 matthiasgoergens