-
-
Notifications
You must be signed in to change notification settings - Fork 30.7k
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
gh-102471: convert decimal module to use import/export API for ints (PEP 757) #127925
base: main
Are you sure you want to change the base?
Conversation
Let's not hide this. Maybe someone is using it (it was removed then restored IIRC).
Not needed I think, unless you want to indicate the performance gain (it's always nice to know that something is faster). I did report the improvements of |
Co-authored-by: Bénédikt Tran <[email protected]>
n = (mpd_sizeinbase(x, 2) + bpd - 1) / bpd; | ||
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 comment
The 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".
I've updated the pr descriptions with my research. So far, I've found just one use case. At least, I think we should deprecate (not soft) this. This apparently affects not so much projects and there is now a public alternative. @picnixz, what do you think? |
I would be fine with deprecating it, saying which alternative to use, so that we can simply remove it in some later versions. I think Victor was the one who removed and restored it so we should ask him as well. |
If you prefer doing it in a follow-up PR because you fear it would be too hard to review, then it's better. If the change is minimal, we can do it this one (I didn't check the code to change) |
You can estimate them looking on the gmpy2 pr (referenced in the PEP): aleaxit/gmpy#495 In principle, I don't think that this will complicate review to much. On another hand, changes looks logically independent. I would rather include here deprecation. |
|
Benchmark hidden because not significant (1): int(Decimal(1<<300))
bench.py