Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
gh-102471, PEP 757: Add PyLong import and export API#121339
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes from1 commit
f4fdbf2c2e568ef0d9525b19764f6f7fd11080e0791a7902fb70a6dd07552a70d0f942762c33a20be7a3d92bf1eb3b02a2caca2d74221a4937b1d49d70a1214aa25f690973d45d3e224c7d7cb2a3d601ac04926806b196b3e8d29686c68c2a8fd669a04f9d0b2be94aca98ad1167d75e5e53a5bc24789f0422f9da529a483db44f31d2863ed663511816798d033bd6536b87d494d852ea72ff8353d584b577598ab08cd55eaebef303248c70a26f9788a62fe45517ab92007d16d3cb80File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
- Loading branch information
Uh oh!
There was an error while loading.Please reload this page.
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -619,10 +619,12 @@ Export API | ||||||||||||||||
| .. c:struct:: PyLongLayout | ||||||||||||||||
| Layout of an array of "digits" ("limbs" in the GMP terminology), used to | ||||||||||||||||
| represent absolute value for arbitrary precision integers. | ||||||||||||||||
| Use :c:func:`PyLong_GetNativeLayout` to get the native layout of Python | ||||||||||||||||
| :class:`int` objects, used internally for integers with "big enough" | ||||||||||||||||
| absolute value. | ||||||||||||||||
| See also :data:`sys.int_info` which exposes similar information to Python. | ||||||||||||||||
vstinner marked this conversation as resolved. OutdatedShow resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||||||||||||||||
| @@ -655,6 +657,11 @@ Export API | ||||||||||||||||
| See the :c:struct:`PyLongLayout` structure. | ||||||||||||||||
| The function must not be called before Python initialization nor after | ||||||||||||||||
| Python finalization. The returned layout is valid until Python is | ||||||||||||||||
| finalized. The layout is the same for all Python sub-interpreters and | ||||||||||||||||
| so it can be cached. | ||||||||||||||||
vstinner marked this conversation as resolved. OutdatedShow resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||||||||||||||||
| .. c:struct:: PyLongExport | ||||||||||||||||
| @@ -695,9 +702,6 @@ Export API | ||||||||||||||||
| On success, set *\*export_long* and return 0. | ||||||||||||||||
| On error, set an exception and return -1. | ||||||||||||||||
vstinner marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||||||||||||||||
| If *export_long.digits* is not ``NULL``, :c:func:`PyLong_FreeExport` must be | ||||||||||||||||
| called when the export is no longer needed. | ||||||||||||||||
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Suggested change
Lets see if we can restore this in a that way. It might be helpful for e.g. Sage, which doesn't support PyPy. MemberAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. I would prefer to not add this note. It was controversial during PEP 757 design. @serhiy-storchaka@encukou: What do you think? Would you be ok to declare that the PyLong_Export() function cannot fail if the argument is a Python int? Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more.
It was proposed unconditionally, not as CPython's implementation detail. Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. I'm fine with it, as an implementation detail. Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. | ||||||||||||||||
| @@ -718,7 +722,8 @@ The :c:type:`PyLongWriter` API can be used to import an integer. | ||||||||||||||||
| A Python :class:`int` writer instance. | ||||||||||||||||
| The instance must be destroyed by :c:func:`PyLongWriter_Finish` or | ||||||||||||||||
| :c:func:`PyLongWriter_Discard`. | ||||||||||||||||
| .. c:function:: PyLongWriter* PyLongWriter_Create(int negative, Py_ssize_t ndigits, void **digits) | ||||||||||||||||
| @@ -733,10 +738,11 @@ The :c:type:`PyLongWriter` API can be used to import an integer. | ||||||||||||||||
| *ndigits* is the number of digits in the *digits* array. It must be | ||||||||||||||||
| greater than or equal to 0. | ||||||||||||||||
vstinner marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||||||||||||||||
| The caller can either initialize the array of digits *digits* and then call | ||||||||||||||||
| :c:func:`PyLongWriter_Finish` to get a Python :class:`int`, or call | ||||||||||||||||
| :c:func:`PyLongWriter_Discard` to destroy the writer instance. Digits must | ||||||||||||||||
| be in the range [``0``; ``(1 << sys.int_info.bits_per_digit) - 1``]. Unused | ||||||||||||||||
| digits must be set to ``0``. | ||||||||||||||||
| .. c:function:: PyObject* PyLongWriter_Finish(PyLongWriter *writer) | ||||||||||||||||
| @@ -749,4 +755,4 @@ The :c:type:`PyLongWriter` API can be used to import an integer. | ||||||||||||||||
| .. c:function:: void PyLongWriter_Discard(PyLongWriter *writer) | ||||||||||||||||
| Discarda :c:type:`PyLongWriter` created by :c:func:`PyLongWriter_Create`. | ||||||||||||||||
vstinner marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||||||||||||||||