mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
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>
This commit is contained in:
parent
abb90ba46c
commit
8ff7efb46d
7 changed files with 164 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue