picop.cyfunction#
Function-object helpers.
- picop.cyfunction.func_check(o)#
Return True if
ois a Python function object (PyFunction_Check).
- picop.cyfunction.func_eq(a, b)#
Return True if
a is b(function-object identity; CPythonobject.__eq__).
- picop.cyfunction.func_get_annotations(op)#
Return the annotations dict of
op, orNonewhen unset.
- picop.cyfunction.func_get_closure(op)#
Return closure cell tuple of
op, orNone.
- picop.cyfunction.func_get_code(op)#
Return the code object of function
op(owned ref).
- picop.cyfunction.func_get_defaults(op)#
Return argument defaults tuple of
op, orNone.
- picop.cyfunction.func_get_globals(op)#
Return the globals dict of function
op(owned ref).
- picop.cyfunction.func_get_kw_defaults(op)#
Return keyword-only defaults of
opas a dict, orNone.
- picop.cyfunction.func_get_module(op)#
Return
op.__module__(owned ref), orNoneif unset.
- picop.cyfunction.func_new(code, globals)#
Return a new function from
codeandglobals(PyFunction_New).
- picop.cyfunction.func_new_with_qualname(code, globals, qualname)#
Return a new function from
code,globalsandqualname.Notes
PyFunction_NewWithQualName— what the compiler uses for nested functions, so__qualname__is correct from the start.globalsmust be a dict.
- picop.cyfunction.func_set_annotations(op, annotations)#
Set annotations on
op(Noneor dict).Notes
Returns
0on success; errors raise — do not use the status as a bool.
- picop.cyfunction.func_set_closure(op, closure)#
Set closure on
op(Noneor cell tuple).Notes
Slower than the plain-Python equivalent
lambda fn, c: 0(Tier A 1.09x); function defaults without the Python attribute machinery.Returns
0on success; errors raise — do not use the status as a bool.
- picop.cyfunction.func_set_defaults(op, defaults)#
Set argument defaults on
op(Noneor tuple).Notes
Returns
0on success; errors raise — do not use the status as a bool.