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:
RUANG (James Roy) 2024-11-12 21:18:06 +08:00 committed by GitHub
parent abb90ba46c
commit 8ff7efb46d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 164 additions and 0 deletions

View file

@ -105,6 +105,30 @@ pylong_getsign(PyObject *module, PyObject *arg)
}
static PyObject *
pylong_ispositive(PyObject *module, PyObject *arg)
{
NULLABLE(arg);
RETURN_INT(PyLong_IsPositive(arg));
}
static PyObject *
pylong_isnegative(PyObject *module, PyObject *arg)
{
NULLABLE(arg);
RETURN_INT(PyLong_IsNegative(arg));
}
static PyObject *
pylong_iszero(PyObject *module, PyObject *arg)
{
NULLABLE(arg);
RETURN_INT(PyLong_IsZero(arg));
}
static PyObject *
pylong_aspid(PyObject *module, PyObject *arg)
{
@ -124,6 +148,9 @@ static PyMethodDef test_methods[] = {
{"pylong_fromnativebytes", pylong_fromnativebytes, METH_VARARGS},
{"pylong_getsign", pylong_getsign, METH_O},
{"pylong_aspid", pylong_aspid, METH_O},
{"pylong_ispositive", pylong_ispositive, METH_O},
{"pylong_isnegative", pylong_isnegative, METH_O},
{"pylong_iszero", pylong_iszero, METH_O},
{NULL},
};