Skip to content

Commit

Permalink
speed up export
Browse files Browse the repository at this point in the history
  • Loading branch information
skirpichev committed Dec 17, 2024
1 parent 6ab20f1 commit 83471fd
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion Modules/_decimal/_decimal.c
Original file line number Diff line number Diff line change
Expand Up @@ -2350,7 +2350,16 @@ dec_from_long(decimal_state *state, PyTypeObject *type, PyObject *v,
PyLong_FreeExport(&export_long);
}
else {
mpd_qset_i64(MPD(dec), export_long.value, ctx, status);
const int64_t value = export_long.value;

if (INT32_MIN <= value && value <= INT32_MAX) {
_dec_settriple(dec, value < 0 ? MPD_NEG : MPD_POS,
Py_ABS(value), 0);
mpd_qfinalize(MPD(dec), ctx, status);
}
else {
mpd_qset_i64(MPD(dec), value, ctx, status);
}
}
return dec;
}
Expand Down

0 comments on commit 83471fd

Please sign in to comment.