MCPcopy Create free account
hub / github.com/BasisResearch/lean.py / lean_py_of_lean_obj

Function lean_py_of_lean_obj

LeanPy/native/python_bridge.c:1176–1191  ·  view source on GitHub ↗

* lean_py_of_lean_obj: wrap any lean_object* as a Python LeanObjHandle, * then return it as a Lean Py (external class wrapping PyObject*). * * @[extern "lean_py_of_lean_obj"] * opaque Py.ofLeanObj (obj : @& α) : IO Py */

Source from the content-addressed store, hash-verified

1174
1175/* ---- Lean-facing FFI ------------------------------------------------- */
1176
1177/*
1178 * lean_py_of_lean_obj: wrap any lean_object* as a Python LeanObjHandle,
1179 * then return it as a Lean Py (external class wrapping PyObject*).
1180 *
1181 * @[extern "lean_py_of_lean_obj"]
1182 * opaque Py.ofLeanObj (obj : @& α) : IO Py
1183 */
1184LEAN_EXPORT lean_obj_res lean_py_of_lean_obj(b_lean_obj_arg obj, lean_obj_arg world) {
1185 (void)world;
1186 ENSURE_INIT(); WITH_GIL();
1187
1188 PyObject *type = get_lean_obj_handle_type();
1189 if (!type) return raise_io_error("LeanPy: failed to create LeanObjHandle type");
1190
1191 PyObject *inst = p_PyType_GenericAlloc(type, 0);
1192 if (!inst) return raise_py_error();
1193
1194 LeanObjHandle *h = (LeanObjHandle *)inst;

Callers

nothing calls this directly

Calls 5

get_lean_obj_handle_typeFunction · 0.85
raise_io_errorFunction · 0.85
raise_py_errorFunction · 0.85
lean_incFunction · 0.85
wrap_pyobjectFunction · 0.85

Tested by

no test coverage detected