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
Update Include/internal/pycore_pymem.h
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
  • Loading branch information
corona10 and kumaraditya303 authored Jun 10, 2025
commit 388f0ca7e5078458dd6c2b724619c429ff94b7dd
5 changes: 2 additions & 3 deletions Include/internal/pycore_pymem.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,8 @@ 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.
// Same as `Py_XSETREF` but in free-threading, it stores the object atomically
// and queues the old object to be decrefed at a safe point using QSBR
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