Skip to content

Conversation

vstinner
Copy link
Member

@vstinner vstinner commented Oct 7, 2024

These functions cannot fail.

Copy link
Member

@corona10 corona10 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@vstinner vstinner merged commit 0377547 into python:main Oct 7, 2024
40 checks passed
@vstinner vstinner deleted the long_invmod branch October 7, 2024 17:54
@vstinner
Copy link
Member Author

vstinner commented Oct 7, 2024

Merged, thanks for reviews!

return NULL;
}
Py_INCREF(a);
PyLongObject *b = (PyLongObject *)Py_NewRef(_PyLong_GetOne());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vstinner Out of curiosity: why did you add the Py_NewRef when _PyLong_GetOne is documented to return an immortal singleton?
(or can modern compilers optimize this away?)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Py_NewRef() is useless. I added it because the code wants a strong refererence and I didn't pay attention that these two constants are immortal.

(or can modern compilers optimize this away?)

No, Py_NewRef() is not optimized.

See also my PR gh-124076 attempt.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants