8000 gh-133931: Introduce _PyObject_XSetRefDelayed to replace Py_XSETREF by corona10 · Pull Request #134377 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-133931: Introduce _PyObject_XSetRefDelayed to replace Py_XSETREF #134377

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

Merged
merged 21 commits into from
Jun 17, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add comment
  • Loading branch information
corona10 committed Jun 7, 2025
commit 12a701657565b44d44a4b19f6449b2ffb4ef65c5
3 changes: 3 additions & 0 deletions Include/internal/pycore_pymem.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ static inline void _PyObject_XDecRefDelayed(PyObject *obj)
#endif

#ifdef Py_GIL_DISABLED
// This is the delayed-free equivalent of Py_XSETREF(), providing the same
// atomic reference assignment semantics but with deferred cleanup suitable
// for concurrent access patterns in free-threaded Python.
PyAPI_FUNC(void) _PyObject_XSetRefDelayed(PyObject **p_obj, PyObject *obj);
Copy link
Member

Choose a reason for hiding this comment

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

Why not adding this function to pycore_object.h header instead?

Copy link
Member Author

Choose a reason for hiding this comment

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

Because _PyObject_XDecRefDelayed is also declared here?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's fine to place _PyObject_XDecRefDelayed and _PyObject_XSetRefDelayed in pycore_object.h instead if you prefer. (I agree that they should probably be in the same header as each other).

#else
static inline void _PyObject_XSetRefDelayed(PyObject **p_obj, PyObject *obj)
Expand Down
Loading
0