When reading the issue #27725, I saw that x_sub() of Objects/longobject.c is too careful just to change the sign of the newly created number: z cannot be shared at the end of the function, before z is normalized. Attached patch simplifies the code. See also the issue #27073, another similar simplification.
> I would add a comment as to why the assertion is there, otherwise it seems somewhat random that it exists. Hum. Maybe it's even better to remove the assertion :-)
LGTM. Maybe use size_a instead of Py_SIZE(z)? And look at "sign". Currently it takes values 1 and -1. Is it worth to replace it with boolean variable "negative"? Or Py_ssize_t variable size_z that takes values size_a and -size_a?
Serhiy Storchaka: "LGTM." Oh, you posted your comment while I was pushing the patch after Brett wrote LGTM on the review (not on the bug tracker). > Maybe use size_a instead of Py_SIZE(z)? > And look at "sign". Currently it takes values 1 and -1. Is it worth to replace it with boolean variable "negative"? Or Py_ssize_t variable size_z that takes values size_a and -size_a? Hum, I don't know what is the best. I don't think that it has an impact on performance. Feel free to modify directly the code, your proposed changes look safe and simple enough.
History
Date
User
Action
Args
2022-04-11 14:58:34
admin
set
github: 71973
2016-08-17 21:13:53
vstinner
set
messages: +
2016-08-17 17:50:46
vstinner
set
status: open -> closedresolution: fixedmessages: +