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

Function lean_py_of_list

LeanPy/native/python_bridge.c:515–527  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

513 size_t n = lean_string_size(s) - 1; /* size includes terminating NUL */
514 return ok_owned_or_err(p_PyUnicode_DecodeUTF8(cs, (Py_ssize_t)n, NULL));
515}
516
517LEAN_EXPORT lean_obj_res lean_py_of_bytes(b_lean_obj_arg ba, lean_obj_arg world) {
518 (void)world; ENSURE_INIT(); WITH_GIL();
519 Py_ssize_t n = (Py_ssize_t) lean_sarray_size(ba);
520 const char *p = (const char *) lean_sarray_cptr(ba);
521 return ok_owned_or_err(p_PyBytes_FromStringAndSize(p, n));
522}
523
524LEAN_EXPORT lean_obj_res lean_py_of_list(b_lean_obj_arg arr, lean_obj_arg world) {
525 (void)world; ENSURE_INIT(); WITH_GIL();
526 size_t n = lean_array_size(arr);
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);

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