Skip to content

gh-112069: Make PySet_GET_SIZE to be atomic safe. #118053

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 1 commit into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 4 additions & 0 deletions Include/cpython/setobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ typedef struct {
(assert(PyAnySet_Check(so)), _Py_CAST(PySetObject*, so))

static inline Py_ssize_t PySet_GET_SIZE(PyObject *so) {
#ifdef Py_GIL_DISABLED
return _Py_atomic_load_ssize_relaxed(&(_PySet_CAST(so)->used));
#else
return _PySet_CAST(so)->used;
#endif
}
#define PySet_GET_SIZE(so) PySet_GET_SIZE(_PyObject_CAST(so))
1 change: 0 additions & 1 deletion Objects/setobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -2080,7 +2080,6 @@ set_issuperset_impl(PySetObject *so, PyObject *other)
Py_RETURN_TRUE;
}

// TODO: Make thread-safe in free-threaded builds
static PyObject *
set_richcompare(PySetObject *v, PyObject *w, int op)
{
Expand Down
Loading