int PyLong_IsPositive(PyObject *);
int PyLong_IsNegative(PyObject *);
int PyLong_IsZero(PyObject *);
They should be identical to existing private functions _PyLong_IsPositive(), _PyLong_IsNegative() and _PyLong_IsZero(), except that the argument is PyObject * instead of PyLongObject *.
The private functions are much more used in the CPython code than _PyLong_Sign (numbers are not accurate):
26 _PyLong_IsZero
7 _PyLong_IsPositive
71 _PyLong_IsNegative
8 _PyLong_Sign
Some of cases that use _PyLong_Sign could use _PyLong_IsNegative etc instead. It is expected that they will be more used in the user code too.
They are faster than PyLong_GetSign because they have less code.
They are also more convenient, because you do not need to introduce a variable for result and can use them in expression. For example:
if (PyLong_IsNegative(obj)) {
vs
int sign;
(void)PyLong_GetSign(obj, &sign);
if (sign < 0) {
They should be identical to existing private functions
_PyLong_IsPositive(),_PyLong_IsNegative()and_PyLong_IsZero(), except that the argument isPyObject *instead ofPyLongObject *.The private functions are much more used in the CPython code than
_PyLong_Sign(numbers are not accurate):Some of cases that use
_PyLong_Signcould use_PyLong_IsNegativeetc instead. It is expected that they will be more used in the user code too.They are faster than
PyLong_GetSignbecause they have less code.They are also more convenient, because you do not need to introduce a variable for result and can use them in expression. For example:
vs