diff options
author | RUANG (James Roy) <longjinyii@outlook.com> | 2024-11-12 13:18:06 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-12 13:18:06 (GMT) |
commit | 8ff7efb46d34ee454239bd86ff5136f386b9749b (patch) | |
tree | 0dae8e79e19bbec4ea0546670604b4ef0f8a590b /Doc/c-api/long.rst | |
parent | abb90ba46c597a1b192027e914ad312dd62d2462 (diff) | |
download | cpython-8ff7efb46d34ee454239bd86ff5136f386b9749b.zip cpython-8ff7efb46d34ee454239bd86ff5136f386b9749b.tar.gz cpython-8ff7efb46d34ee454239bd86ff5136f386b9749b.tar.bz2 |
gh-126061: Add PyLong_IsPositive/Zero/Negative() functions (#126065)
Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Diffstat (limited to 'Doc/c-api/long.rst')
-rw-r--r-- | Doc/c-api/long.rst | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/Doc/c-api/long.rst b/Doc/c-api/long.rst index 9ff3e52..32bb451 100644 --- a/Doc/c-api/long.rst +++ b/Doc/c-api/long.rst @@ -582,6 +582,39 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate. .. versionadded:: 3.14 +.. c:function:: int PyLong_IsPositive(PyObject *obj) + + Check if the integer object *obj* is positive (``obj > 0``). + + If *obj* is an instance of :c:type:`PyLongObject` or its subtype, + return ``1`` when it's positive and ``0`` otherwise. Else set an + exception and return ``-1``. + + .. versionadded:: next + + +.. c:function:: int PyLong_IsNegative(PyObject *obj) + + Check if the integer object *obj* is negative (``obj < 0``). + + If *obj* is an instance of :c:type:`PyLongObject` or its subtype, + return ``1`` when it's negative and ``0`` otherwise. Else set an + exception and return ``-1``. + + .. versionadded:: next + + +.. c:function:: int PyLong_IsZero(PyObject *obj) + + Check if the integer object *obj* is zero. + + If *obj* is an instance of :c:type:`PyLongObject` or its subtype, + return ``1`` when it's zero and ``0`` otherwise. Else set an + exception and return ``-1``. + + .. versionadded:: next + + .. c:function:: PyObject* PyLong_GetInfo(void) On success, return a read only :term:`named tuple`, that holds |