實(shí)例方法對象?
實(shí)例方法是 PyCFunction 的包裝器,也是將 PyCFunction 綁定到類對象的一種新方式。 它替代了原先的調(diào)用 PyMethod_New(func, NULL, class)。
-
PyTypeObject
PyInstanceMethod_Type? 這個(gè)
PyTypeObject實(shí)例代表 Python 實(shí)例方法類型。 它并不對 Python 程序公開。
-
int
PyInstanceMethod_Check(PyObject?*o)? 如果 o 是實(shí)例方法對象 (類型為
PyInstanceMethod_Type) 則返回真值。 形參必須不為NULL。
-
PyObject*
PyInstanceMethod_New(PyObject?*func)? - Return value: New reference.
返回一個(gè)新的實(shí)例方法對象,func 應(yīng)為任意可調(diào)用對象,func 將在實(shí)例方法被調(diào)用時(shí)作為函數(shù)被調(diào)用。
-
PyObject*
PyInstanceMethod_Function(PyObject?*im)? - Return value: Borrowed reference.
返回關(guān)聯(lián)到實(shí)例方法 im 的函數(shù)對象。
-
PyObject*
PyInstanceMethod_GET_FUNCTION(PyObject?*im)? - Return value: Borrowed reference.
宏版本的
PyInstanceMethod_Function(),略去了錯(cuò)誤檢測。
方法對象?
方法是綁定的函數(shù)對象。 方法總是會被綁定到一個(gè)用戶自定義類的實(shí)例。 未綁定方法(綁定到一個(gè)類的方法)已不再可用。
-
PyTypeObject
PyMethod_Type? 這個(gè)
PyTypeObject實(shí)例代表 Python 方法類型。 它作為types.MethodType向 Python 程序公開。
-
int
PyMethod_Check(PyObject?*o)? 如果 o 是方法對象 (類型為
PyMethod_Type) 則返回真值。 形參必須不為NULL。
-
PyObject*
PyMethod_New(PyObject?*func, PyObject?*self)? - Return value: New reference.
返回一個(gè)新的方法對象,func 應(yīng)為任意可調(diào)用對象,self 為該方法應(yīng)綁定的實(shí)例。 在方法被調(diào)用時(shí) func 將作為函數(shù)被調(diào)用。 self 必須不為
NULL。
-
PyObject*
PyMethod_Function(PyObject?*meth)? - Return value: Borrowed reference.
返回關(guān)聯(lián)到方法 meth 的函數(shù)對象。
-
PyObject*
PyMethod_GET_FUNCTION(PyObject?*meth)? - Return value: Borrowed reference.
宏版本的
PyMethod_Function(),略去了錯(cuò)誤檢測。
-
PyObject*
PyMethod_Self(PyObject?*meth)? - Return value: Borrowed reference.
返回關(guān)聯(lián)到方法 meth 的實(shí)例。
-
PyObject*
PyMethod_GET_SELF(PyObject?*meth)? - Return value: Borrowed reference.
宏版本的
PyMethod_Self(),省略了錯(cuò)誤檢測。
-
int
PyMethod_ClearFreeList()? 清空釋放列表。 返回所釋放的條目數(shù)。
