Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32.3k
gh-127937: convert decimal module to use import API for ints (PEP 757)#127925
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes from1 commit
80f1a04
c13b7d2
589f926
f27adef
6669b89
05ec274
6e46bc1
7f0061f
bae0234
4e0460c
87ded2e
541441e
6ab20f1
83471fd
cb169f7
0ea0d59
61e76d2
90bafc1
c117956
7b97855
7e0e9a9
fec6666
5a00ee2
37ec841
d4728c4
f6a4afb
4b07189
4db7917
0fec6e1
59636f9
b8bf49f
a8189e6
3854262
336e881
e658f2b
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
- Loading branch information
Uh oh!
There was an error while loading.Please reload this page.
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -2335,24 +2335,18 @@ dec_from_long(decimal_state *state, PyTypeObject *type, PyObject *v, | ||
return NULL; | ||
} | ||
if (export_long.digits) { | ||
const uint8_t sign = export_long.negative ? MPD_NEG : MPD_POS; | ||
skirpichev marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
const Py_ssize_t len = export_long.ndigits; | ||
#if PYLONG_BITS_IN_DIGIT == 30 | ||
mpd_qimport_u32(MPD(dec), export_long.digits, len, sign, | ||
PyLong_BASE, ctx, status); | ||
#elif PYLONG_BITS_IN_DIGIT == 15 | ||
mpd_qimport_u16(MPD(dec), export_long.digits, len, sign, | ||
PyLong_BASE, ctx, status); | ||
#else | ||
#error "PYLONG_BITS_IN_DIGIT should be 15 or 30" | ||
#endif | ||
PyLong_FreeExport(&export_long); | ||
} | ||
else { | ||
@@ -3648,7 +3642,6 @@ dec_as_long(PyObject *dec, PyObject *context, int round) | ||
mpd_t *x; | ||
mpd_context_t workctx; | ||
uint32_t status = 0; | ||
if (mpd_isspecial(MPD(dec))) { | ||
if (mpd_isnan(MPD(dec))) { | ||
@@ -3683,8 +3676,7 @@ dec_as_long(PyObject *dec, PyObject *context, int round) | ||
return PyLong_FromInt64(val); | ||
} | ||
n = (mpd_sizeinbase(x, 2) + PyLong_SHIFT - 1)/PyLong_SHIFT; | ||
PyLongWriter *writer = PyLongWriter_Create(mpd_isnegative(x), n, | ||
(void**)&ob_digit); | ||
/* mpd_sizeinbase can overestimate size by 1 digit, set it to zero. */ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. BTW, this looks as a bug in the mpdecimal. C.f. the GNU GMP, the mpz_sizeinbase docs says: "If base is a power of 2, the result is always exact". | ||
Uh oh!
There was an error while loading.Please reload this page.