diff options
author | Brandt Bucher <brandt@python.org> | 2022-01-16 16:06:37 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-16 16:06:37 (GMT) |
commit | 5cd9a162cd02a3d0f1b0a182d80feeb17439e84f (patch) | |
tree | 3a80de2f3551e23f85f4c63200e5ecd844dfa374 /Modules | |
parent | 09087b8519316608b85131ee7455b664c00c38d2 (diff) | |
download | cpython-5cd9a162cd02a3d0f1b0a182d80feeb17439e84f.zip cpython-5cd9a162cd02a3d0f1b0a182d80feeb17439e84f.tar.gz cpython-5cd9a162cd02a3d0f1b0a182d80feeb17439e84f.tar.bz2 |
bpo-46361: Fix "small" `int` caching (GH-30583)
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_decimal/_decimal.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/Modules/_decimal/_decimal.c b/Modules/_decimal/_decimal.c index 7fc7315..35a1156 100644 --- a/Modules/_decimal/_decimal.c +++ b/Modules/_decimal/_decimal.c @@ -3394,6 +3394,13 @@ dec_as_long(PyObject *dec, PyObject *context, int round) return NULL; } + if (n == 1) { + sdigit val = mpd_arith_sign(x) * ob_digit[0]; + mpd_free(ob_digit); + mpd_del(x); + return PyLong_FromLong(val); + } + assert(n > 0); pylong = _PyLong_New(n); if (pylong == NULL) { |