mirror of
https://github.com/python/cpython.git
synced 2025-08-24 02:35:59 +00:00
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
This commit is contained in:
parent
9f67042f28
commit
2d76be251d
3 changed files with 70 additions and 30 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue