列表对象 ¶
-
PyTypeObject
PyList_Type
¶
-
属于
稳定 ABI (应用程序二进制接口)
.
此实例的
PyTypeObjectrepresents the Python list type. This is the same object aslist在 Python 层。
-
int
PyList_Check
(
PyObject
*
p
)
¶
-
返回 True 若 p is a list object or an instance of a subtype of the list type. This function always succeeds.
-
int
PyList_CheckExact
(
PyObject
*
p
)
¶
-
返回 True 若 p is a list object, but not an instance of a subtype of the list type. This function always succeeds.
-
PyObject
*
PyList_New
(
Py_ssize_t
len
)
¶
-
返回值:新引用。
属于
稳定 ABI (应用程序二进制接口)
.
Return a new list of length len 当成功时,或
NULL当故障时。注意
若 len is greater than zero, the returned list object’s items are set to
NULL. Thus you cannot use abstract API functions such asPySequence_SetItem()or expose the object to Python code before setting all items to a real object withPyList_SetItem()orPyList_SET_ITEM(). The following APIs are safe APIs before the list is fully initialized:PyList_SetItem()andPyList_SET_ITEM().
-
Py_ssize_t
PyList_Size
(
PyObject
*
list
)
¶
-
属于
稳定 ABI (应用程序二进制接口)
.
Return the length of the list object in list ; this is equivalent to
len(list)on a list object.
-
Py_ssize_t
PyList_GET_SIZE
(
PyObject
*
list
)
¶
-
类似于
PyList_Size(), but without error checking.
-
PyObject
*
PyList_GetItemRef
(
PyObject
*
list
,
Py_ssize_t
index
)
¶
-
返回值:新引用。
属于
稳定 ABI (应用程序二进制接口)
since version 3.13.
Return the object at position index in the list pointed to by list . The position must be non-negative; indexing from the end of the list is not supported. If index is out of bounds (
<0 or >=len(list)), returnNULLand set anIndexError异常。3.13 版添加。