8000 gh-134043: use `_Py_dict_lookup_threadsafe_stackref` for dict lookup in `_PyObject_GetMethodStackRef` by kumaraditya303 · Pull Request #136412 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-134043: use _Py_dict_lookup_threadsafe_stackref for dict lookup in _PyObject_GetMethodStackRef #136412

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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

kumaraditya303
Copy link
Contributor
@kumaraditya303 kumaraditya303 commented Jul 8, 2025

Changes _PyObject_GetMethodStackRef to use _Py_dict_lookup_threadsafe_stackref to avoid reference counting on deferred objects.

@kumaraditya303 kumaraditya303 marked this pull request as ready for review July 8, 2025 12:05
@kumaraditya303 kumaraditya303 requested a review from colesbury July 8, 2025 12:05
Copy link
Contributor
@colesbury colesbury left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. We should add a scaling benchmark to ftscalingbench.py for the relevant access pattern
  2. We probably need to avoid Py_INCREF(dict) and that's going to require refactoring. You can safely avoid Py_INCREF(dict) in the same cases where _Py_dict_lookup_threadsafe_stackref is relevant: when the dictionary keys are DICT_KEYS_UNICODE.

@colesbury
Copy link
Contributor

This needs more refactoring - we can't load the keys twice like this because the condition might not hold.

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.

2 participants
0