Instance Method Objects¶
An instance method is a wrapper for aPyCFunction and the new wayto bind aPyCFunction to a class object. It replaces the former callPyMethod_New(func,NULL,class).
- PyTypeObject
PyInstanceMethod_Type¶ This instance of
PyTypeObjectrepresents the Python instancemethod type. It is not exposed to Python programs.
- int
PyInstanceMethod_Check(PyObject *o)¶ Return true ifo is an instance method object (has type
PyInstanceMethod_Type). The parameter must not beNULL.
- PyObject*
PyInstanceMethod_New(PyObject *func)¶ - Return value: New reference.
Return a new instance method object, withfunc being any callable objectfunc is the function that will be called when the instance method iscalled.
- PyObject*
PyInstanceMethod_Function(PyObject *im)¶ - Return value: Borrowed reference.
Return the function object associated with the instance methodim.
- PyObject*
PyInstanceMethod_GET_FUNCTION(PyObject *im)¶ - Return value: Borrowed reference.
Macro version of
PyInstanceMethod_Function()which avoids error checking.
Method Objects¶
Methods are bound function objects. Methods are always bound to an instance ofa user-defined class. Unbound methods (methods bound to a class object) areno longer available.
- PyTypeObject
PyMethod_Type¶ This instance of
PyTypeObjectrepresents the Python method type. Thisis exposed to Python programs astypes.MethodType.
- int
PyMethod_Check(PyObject *o)¶ Return true ifo is a method object (has type
PyMethod_Type). Theparameter must not beNULL.
- PyObject*
PyMethod_New(PyObject *func,PyObject *self)¶ - Return value: New reference.
Return a new method object, withfunc being any callable object andselfthe instance the method should be bound.func is the function that willbe called when the method is called.self must not be
NULL.
- PyObject*
PyMethod_Function(PyObject *meth)¶ - Return value: Borrowed reference.
Return the function object associated with the methodmeth.
- PyObject*
PyMethod_GET_FUNCTION(PyObject *meth)¶ - Return value: Borrowed reference.
Macro version of
PyMethod_Function()which avoids error checking.
- PyObject*
PyMethod_Self(PyObject *meth)¶ - Return value: Borrowed reference.
Return the instance associated with the methodmeth.
- PyObject*
PyMethod_GET_SELF(PyObject *meth)¶ - Return value: Borrowed reference.
Macro version of
PyMethod_Self()which avoids error checking.
- int
PyMethod_ClearFreeList()¶ Clear the free list. Return the total number of freed items.