diff options
author | Victor Stinner <vstinner@python.org> | 2021-03-22 10:58:59 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-22 10:58:59 (GMT) |
commit | 39f643614d03748a5fad462fe7ed26a174a522fa (patch) | |
tree | db22541072a1688fdfe7f65166d87e6261f25229 /Python/dtoa.c | |
parent | 86883d40e93acae980e52b90fddd7d042e439beb (diff) | |
download | cpython-39f643614d03748a5fad462fe7ed26a174a522fa.zip cpython-39f643614d03748a5fad462fe7ed26a174a522fa.tar.gz cpython-39f643614d03748a5fad462fe7ed26a174a522fa.tar.bz2 |
Revert "bpo-40521: Make dtoa bigint free list per-interpreter (GH-24821)" (GH-24964)
This reverts commit 5bd1059184b154d339f1bd53d23c98b5bcf14c8c.
Diffstat (limited to 'Python/dtoa.c')
-rw-r--r-- | Python/dtoa.c | 36 |
1 files changed, 17 insertions, 19 deletions
diff --git a/Python/dtoa.c b/Python/dtoa.c index c7002e5..e629b29 100644 --- a/Python/dtoa.c +++ b/Python/dtoa.c @@ -119,16 +119,6 @@ #include "Python.h" #include "pycore_dtoa.h" -#include "pycore_interp.h" -#include "pycore_pystate.h" - -#define ULong _PyDtoa_ULong -#define Long _PyDtoa_Long -#define ULLong _PyDtoa_ULLong -#define Kmax _PyDtoa_Kmax - -typedef struct _PyDtoa_Bigint Bigint; - /* if PY_NO_SHORT_FLOAT_REPR is defined, then don't even try to compile the following code */ @@ -164,6 +154,11 @@ typedef struct _PyDtoa_Bigint Bigint; #error "doubles and ints have incompatible endianness" #endif + +typedef uint32_t ULong; +typedef int32_t Long; +typedef uint64_t ULLong; + #undef DEBUG #ifdef Py_DEBUG #define DEBUG @@ -302,6 +297,8 @@ BCinfo { #define FFFFFFFF 0xffffffffUL +#define Kmax 7 + /* struct Bigint is used to represent arbitrary-precision integers. These integers are stored in sign-magnitude format, with the magnitude stored as an array of base 2**32 digits. Bigints are always normalized: if x is a @@ -324,6 +321,14 @@ BCinfo { significant (x[0]) to most significant (x[wds-1]). */ +struct +Bigint { + struct Bigint *next; + int k, maxwds, sign, wds; + ULong x[1]; +}; + +typedef struct Bigint Bigint; #ifndef Py_USING_MEMORY_DEBUGGER @@ -346,13 +351,7 @@ BCinfo { Bfree to PyMem_Free. Investigate whether this has any significant performance on impact. */ - -/* Get Bigint freelist from interpreter */ -static Bigint ** -get_freelist(void) { - PyInterpreterState *interp = _PyInterpreterState_GET(); - return interp->dtoa_freelist; -} +static Bigint *freelist[Kmax+1]; /* Allocate space for a Bigint with up to 1<<k digits */ @@ -362,7 +361,7 @@ Balloc(int k) int x; Bigint *rv; unsigned int len; - Bigint **freelist = get_freelist(); + if (k <= Kmax && (rv = freelist[k])) freelist[k] = rv->next; else { @@ -394,7 +393,6 @@ Bfree(Bigint *v) if (v->k > Kmax) FREE((void*)v); else { - Bigint **freelist = get_freelist(); v->next = freelist[v->k]; freelist[v->k] = v; } |