Boolean(布林)物件

Python 中的 boolean 是以整數子類別化來實現的。只有 Py_FalsePy_True 兩個 boolean。因此一般的建立和刪除函式並不適用於 boolean。但下列巨集 (macro) 是可用的。

PyTypeObject PyBool_Type
穩定 ABI 的一部分.

This instance of PyTypeObject represents the Python boolean type; it is the same object as bool in the Python layer.

int PyBool_Check(PyObject *o)

如果 o 的型別為 PyBool_Type 則回傳真值。此函式總是會成功執行。

PyObject *Py_False

The Python False object. This object has no methods and is immortal.

在 3.12 版的變更: Py_False is immortal.

PyObject *Py_True

The Python True object. This object has no methods and is immortal.

在 3.12 版的變更: Py_True is immortal.

Py_RETURN_FALSE

從函式回傳 Py_False

Py_RETURN_TRUE

從函式回傳 Py_True

PyObject *PyBool_FromLong(long v)
回傳值:新的參照。穩定 ABI 的一部分.

根據 v 的實際值來回傳 Py_True 或者 Py_False