mirror of
https://github.com/python/cpython.git
synced 2025-10-06 15:11:58 +00:00
gh-118527: Intern code consts in free-threaded build (#118667)
We already intern and immortalize most string constants. In the free-threaded build, other constants can be a source of reference count contention because they are shared by all threads running the same code objects.
This commit is contained in:
parent
8d8275b0cf
commit
723d4d2fe8
14 changed files with 375 additions and 18 deletions
|
@ -854,6 +854,11 @@ pycore_interp_init(PyThreadState *tstate)
|
|||
return status;
|
||||
}
|
||||
|
||||
status = _PyCode_Init(interp);
|
||||
if (_PyStatus_EXCEPTION(status)) {
|
||||
return status;
|
||||
}
|
||||
|
||||
status = _PyDtoa_Init(interp);
|
||||
if (_PyStatus_EXCEPTION(status)) {
|
||||
return status;
|
||||
|
@ -1827,6 +1832,8 @@ finalize_interp_types(PyInterpreterState *interp)
|
|||
|
||||
_PyTypes_Fini(interp);
|
||||
|
||||
_PyCode_Fini(interp);
|
||||
|
||||
// Call _PyUnicode_ClearInterned() before _PyDict_Fini() since it uses
|
||||
// a dict internally.
|
||||
_PyUnicode_ClearInterned(interp);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue