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

Function lean_py_of_tuple

LeanPy/native/python_bridge.c:529–541  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

527 PyObject *list = p_PyList_New((Py_ssize_t)n);
528 if (!list) return raise_py_error();
529 for (size_t i = 0; i < n; i++) {
530 lean_object *elem = lean_array_get_core(arr, i);
531 PyObject *po = unwrap_pyobject(elem);
532 p_Py_IncRef(po); /* PyList_SetItem steals */
533 p_PyList_SetItem(list, (Py_ssize_t)i, po);
534 }
535 return lean_io_result_mk_ok(wrap_pyobject(list));
536}
537
538LEAN_EXPORT lean_obj_res lean_py_of_tuple(b_lean_obj_arg arr, lean_obj_arg world) {
539 (void)world; ENSURE_INIT(); WITH_GIL();
540 size_t n = lean_array_size(arr);
541 PyObject *tup = p_PyTuple_New((Py_ssize_t)n);
542 if (!tup) return raise_py_error();
543 for (size_t i = 0; i < n; i++) {
544 lean_object *elem = lean_array_get_core(arr, i);

Callers

nothing calls this directly

Calls 5

lean_array_sizeFunction · 0.85
raise_py_errorFunction · 0.85
lean_array_get_coreFunction · 0.85
unwrap_pyobjectFunction · 0.85
wrap_pyobjectFunction · 0.85

Tested by

no test coverage detected