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

Function lean_py_of_int64

LeanPy/native/python_bridge.c:484–494  ·  view source on GitHub ↗

Lean's `Int` may be a small scalar or a big integer (mpz). For now we * support the int64 range and error otherwise; this is what 99% of API * surface needs. Callers needing arbitrary precision can stringify. */

Source from the content-addressed store, hash-verified

482/* Conversions: Lean → Python */
483/* ------------------------------------------------------------------ */
484
485LEAN_EXPORT lean_obj_res lean_py_of_bool(uint8_t b, lean_obj_arg world) {
486 (void)world; ENSURE_INIT(); WITH_GIL();
487 return ok_owned_or_err(p_PyBool_FromLong(b ? 1 : 0));
488}
489
490/* Lean's `Int` may be a small scalar or a big integer (mpz). For now we
491 * support the int64 range and error otherwise; this is what 99% of API
492 * surface needs. Callers needing arbitrary precision can stringify. */
493LEAN_EXPORT lean_obj_res lean_py_of_int64(b_lean_obj_arg n, lean_obj_arg world) {
494 (void)world; ENSURE_INIT(); WITH_GIL();
495 long long v;
496 if (lean_is_scalar(n)) {
497 v = (long long) lean_scalar_to_int64(n);

Callers

nothing calls this directly

Calls 3

lean_is_scalarFunction · 0.85
raise_io_errorFunction · 0.85
ok_owned_or_errFunction · 0.85

Tested by

no test coverage detected