picop.cymethod#

Bound-method helpers.

picop.cymethod.cfunction_check(o)#

Return True if o is a C function object (PyCFunction_Check).

Notes

Matches builtin functions and bound C methods such as [].append; unbound descriptors such as str.join are not PyCFunction objects. A PyCMethod passes here but not in cfunction_check_exact.

Parameters:

o (object)

Return type:

bool

picop.cymethod.cfunction_check_exact(o)#

Return True if o is exactly PyCFunction (PyCFunction_CheckExact).

Parameters:

o (object)

Return type:

bool

picop.cymethod.cfunction_get_self(func)#

Return the object a C function is bound to (its __self__), or None.

Notes

PyCFunction_GetSelf hands back the borrowed m_self: builtin functions report the builtins module and METH_STATIC functions report None. A non-C-function argument raises SystemError.

Parameters:

func (object)

Return type:

object | None

picop.cymethod.classmethod_new(callable)#

Return classmethod(callable) via PyClassMethod_New.

Parameters:

callable (object)

Return type:

object

picop.cymethod.cmethod_check(o)#

Return True if o is a C method (PyCMethod_Check).

Notes

A PyCMethod is a PyCFunction carrying the defining class, built by PyCMethod_New; unbound descriptors such as str.join are not PyCFunction objects at all.

Parameters:

o (object)

Return type:

bool

picop.cymethod.cmethod_check_exact(o)#

Return True if o is exactly PyCMethod (PyCMethod_CheckExact).

Parameters:

o (object)

Return type:

bool

picop.cymethod.method_check(o)#

Return True if o is a bound method (PyMethod_Check).

Parameters:

o (object)

Return type:

bool

picop.cymethod.method_eq(a, b)#

Return True if methods equal (same function + __self__; not identity).

Parameters:
Return type:

bool

picop.cymethod.method_get_function(meth)#

Return the underlying function via checked PyMethod_Function.

Notes

Preferred spelling of method_function.

Parameters:

meth (object)

Return type:

object

picop.cymethod.method_get_self(meth)#

Return __self__ via checked PyMethod_Self.

Notes

Preferred spelling of method_self.

Parameters:

meth (object)

Return type:

object | None

picop.cymethod.method_new(func, self)#

Return a bound method for func and self (PyMethod_New).

Parameters:
Return type:

object

picop.cymethod.staticmethod_new(callable)#

Return staticmethod(callable) via PyStaticMethod_New.

Parameters:

callable (object)

Return type:

object