8000 gh-102471: convert decimal module to use PyLong_Export API (PEP 757) by skirpichev · Pull Request #128267 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-102471: convert decimal module to use PyLong_Export API (PEP 757) #128267

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jan 6, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
10000 Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
address review: drop const (seems wrong for me)
  • Loading branch information
skirpichev committed Jan 5, 2025
commit 3381ddcd29c9c0107a7d720e3b90135a502461b5
8 changes: 4 additions & 4 deletions Modules/_decimal/_decimal.c
Original file line number Diff line number Diff line change
Expand Up @@ -2336,9 +2336,9 @@ dec_from_long(decimal_state *state, PyTypeObject *type, PyObject *v,
}
if (export_long.digits) {
const PyLongLayout *layout = PyLong_GetNativeLayout();
const uint32_t base = (uint32_t)1 << layout->bits_per_digit;
const uint8_t sign = export_long.negative ? MPD_NEG : MPD_POS;
const Py_ssize_t len = export_long.ndigits;
uint32_t base = (uint32_t)1 << layout->bits_per_digit;
uint8_t sign = export_long.negative ? MPD_NEG : MPD_POS;
Py_ssize_t len = export_long.ndigits;

assert(layout->bits_per_digit <= 32);
assert(layout->digits_order == -1);
Expand All @@ -2356,7 +2356,7 @@ dec_from_long(decimal_state *state, PyTypeObject *type, PyObject *v,
PyLong_FreeExport(&export_long);
}
else {
const int64_t value = export_long.value;
int64_t value = export_long.value;

if (-(int64_t)UINT32_MAX <= value && value <= (int64_t)UINT32_MAX) {
_dec_settriple(dec, value < 0 ? MPD_NEG : MPD_POS,
Expand Down
0