mirror of
https://github.com/python/cpython.git
synced 2025-08-03 00:23:06 +00:00
bpo-43753: Add Py_Is() and Py_IsNone() functions (GH-25227)
Add the Py_Is(x, y) function to test if the 'x' object is the 'y' object, the same as "x is y" in Python. Add also the Py_IsNone(), Py_IsTrue(), Py_IsFalse() functions to test if an object is, respectively, the None singleton, the True singleton or the False singleton.
This commit is contained in:
parent
6e468cb16b
commit
09bbebea16
9 changed files with 198 additions and 38 deletions
|
@ -62,6 +62,37 @@ the definition of all other Python objects.
|
|||
See documentation of :c:type:`PyVarObject` above.
|
||||
|
||||
|
||||
.. c:function:: int Py_Is(const PyObject *x, const PyObject *y)
|
||||
|
||||
Test if the *x* object is the *y* object, the same as ``x is y`` in Python.
|
||||
|
||||
.. versionadded:: 3.10
|
||||
|
||||
|
||||
.. c:function:: int Py_IsNone(const PyObject *x)
|
||||
|
||||
Test if an object is the ``None`` singleton,
|
||||
the same as ``x is None`` in Python.
|
||||
|
||||
.. versionadded:: 3.10
|
||||
|
||||
|
||||
.. c:function:: int Py_IsTrue(const PyObject *x)
|
||||
|
||||
Test if an object is the ``True`` singleton,
|
||||
the same as ``x is True`` in Python.
|
||||
|
||||
.. versionadded:: 3.10
|
||||
|
||||
|
||||
.. c:function:: int Py_IsFalse(const PyObject *x)
|
||||
|
||||
Test if an object is the ``False`` singleton,
|
||||
the same as ``x is False`` in Python.
|
||||
|
||||
.. versionadded:: 3.10
|
||||
|
||||
|
||||
.. c:function:: PyTypeObject* Py_TYPE(const PyObject *o)
|
||||
|
||||
Get the type of the Python object *o*.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue