mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +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
|
@ -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},
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue