diff options
author | Sergey B Kirpichev <skirpichev@gmail.com> | 2024-06-03 12:06:31 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-03 12:06:31 (GMT) |
commit | 61d3ab32da92e70bb97a544d76ef2b837501024f (patch) | |
tree | 46a12c70cc83c83e4e6942f0b7a7aa63191addb5 /Doc | |
parent | 367adc91fb9834eb35b168048fd54705621c3f21 (diff) | |
download | cpython-61d3ab32da92e70bb97a544d76ef2b837501024f.zip cpython-61d3ab32da92e70bb97a544d76ef2b837501024f.tar.gz cpython-61d3ab32da92e70bb97a544d76ef2b837501024f.tar.bz2 |
gh-116560: Add PyLong_GetSign() public function (#116561)
Co-authored-by: Victor Stinner <vstinner@python.org>
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/c-api/long.rst | 13 | ||||
-rw-r--r-- | Doc/whatsnew/3.14.rst | 3 |
2 files changed, 16 insertions, 0 deletions
diff --git a/Doc/c-api/long.rst b/Doc/c-api/long.rst index 522c028..a0e111a 100644 --- a/Doc/c-api/long.rst +++ b/Doc/c-api/long.rst @@ -494,6 +494,19 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate. .. versionadded:: 3.13 +.. c:function:: int PyLong_GetSign(PyObject *obj, int *sign) + + Get the sign of the integer object *obj*. + + On success, set *\*sign* to the integer sign (0, -1 or +1 for zero, negative or + positive integer, respectively) and return 0. + + On failure, return -1 with an exception set. This function always succeeds + if *obj* is a :c:type:`PyLongObject` or its subtype. + + .. versionadded:: 3.14 + + .. c:function:: int PyUnstable_Long_IsCompact(const PyLongObject* op) Return 1 if *op* is compact, 0 otherwise. diff --git a/Doc/whatsnew/3.14.rst b/Doc/whatsnew/3.14.rst index 47f3e30..b2dd80b 100644 --- a/Doc/whatsnew/3.14.rst +++ b/Doc/whatsnew/3.14.rst @@ -255,6 +255,9 @@ C API Changes New Features ------------ +* Add :c:func:`PyLong_GetSign` function to get the sign of :class:`int` objects. + (Contributed by Sergey B Kirpichev in :gh:`116560`.) + Porting to Python 3.14 ---------------------- |