picop.cyfunction#

Function-object helpers.

picop.cyfunction.func_check(o)#

Return True if o is a Python function object (PyFunction_Check). :type o: object :param o:

Return type:

bool

picop.cyfunction.func_eq(a, b)#

Return True if a is b (function-object identity; CPython object.__eq__). :type a: object :param a: :type b: object :param b:

Return type:

bool

picop.cyfunction.func_get_closure(op)#

Return closure cell tuple of op, or None. :type op: object :param op:

Return type:

object | None

picop.cyfunction.func_get_code(op)#

Return the code object of function op (owned ref). :type op: object :param op:

Return type:

object

picop.cyfunction.func_get_defaults(op)#

Return argument defaults tuple of op, or None. :type op: object :param op:

Return type:

object | None

picop.cyfunction.func_get_globals(op)#

Return the globals dict of function op (owned ref). :type op: object :param op:

Return type:

object

picop.cyfunction.func_get_module(op)#

Return op.__module__ (owned ref), or None if unset. :type op: object :param op:

Return type:

object | None

picop.cyfunction.func_new(code, globals)#

Return a new function from code and globals (PyFunction_New). :type code: object :param code: :type globals: object :param globals:

Return type:

object

picop.cyfunction.func_set_closure(op, closure)#

Set closure on op (None or cell tuple).

Notes

Returns 0 on success; errors raise — do not use the status as a bool.

Parameters:
Return type:

int

picop.cyfunction.func_set_defaults(op, defaults)#

Set argument defaults on op (None or tuple).

Notes

Returns 0 on success; errors raise — do not use the status as a bool.

Parameters:
Return type:

int