Skip to content

Commit 1bd9bcd

Browse files
committed
gh-155628: Use a relaxed add for the module index allocator
The add is the only access to LAST_MODULE_INDEX anywhere in the codebase; only the uniqueness of each returned index matters, which atomicity alone guarantees.
1 parent b6ddfb0 commit 1bd9bcd

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

Python/import.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ remove_module(PyThreadState *tstate, PyObject *name)
507507
Py_ssize_t
508508
_PyImport_GetNextModuleIndex(void)
509509
{
510-
return _Py_atomic_add_ssize(&LAST_MODULE_INDEX, 1) + 1;
510+
return _Py_atomic_add_ssize_relaxed(&LAST_MODULE_INDEX, 1) + 1;
511511
}
512512

513513
#ifndef NDEBUG

0 commit comments

Comments
 (0)