aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Python/pylifecycle.c
diff options
context:
space:
mode:
authorSam Gross <colesbury@gmail.com>2023-12-07 08:47:55 -0500
committerGitHub <noreply@github.com>2023-12-07 13:47:55 +0000
commit2d76be251d0aee89f76e6fa5a63fa1ad3f2b76cf (patch)
tree3b37a23b864e6ae88736cf7b5fcc64b340d66d4d /Python/pylifecycle.c
parent9f67042f28bf886a9bf30fed6795d26cff255f1e (diff)
downloadcpython-2d76be251d0aee89f76e6fa5a63fa1ad3f2b76cf.tar.gz
cpython-2d76be251d0aee89f76e6fa5a63fa1ad3f2b76cf.zip
gh-111962: Make dtoa thread-safe in `--disable-gil` builds. (#112049)
This updates `dtoa.c` to avoid using the Bigint free-list in --disable-gil builds and to pre-computes the needed powers of 5 during interpreter initialization. * gh-111962: Make dtoa thread-safe in `--disable-gil` builds. This avoids using the Bigint free-list in `--disable-gil` builds and pre-computes the needed powers of 5 during interpreter initialization. * Fix size of cached powers of 5 array. We need the powers of 5 up to 5**512 because we only jump straight to underflow when the exponent is less than -512 (or larger than 308). * Rename Py_NOGIL to Py_GIL_DISABLED * Changes from review * Fix assertion placement
Diffstat (limited to 'Python/pylifecycle.c')
-rw-r--r--Python/pylifecycle.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c
index 95a72eb4704..20bfe1a0b75 100644
--- a/Python/pylifecycle.c
+++ b/Python/pylifecycle.c
@@ -820,6 +820,11 @@ pycore_interp_init(PyThreadState *tstate)
return status;
}
+ status = _PyDtoa_Init(interp);
+ if (_PyStatus_EXCEPTION(status)) {
+ return status;
+ }
+
// The GC must be initialized before the first GC collection.
status = _PyGC_Init(interp);
if (_PyStatus_EXCEPTION(status)) {
@@ -1776,6 +1781,7 @@ finalize_interp_clear(PyThreadState *tstate)
_PyXI_Fini(tstate->interp);
_PyExc_ClearExceptionGroupType(tstate->interp);
_Py_clear_generic_types(tstate->interp);
+ _PyDtoa_Fini(tstate->interp);
/* Clear interpreter state and all thread states */
_PyInterpreterState_Clear(tstate);