Build a Lean Array from a Python iterable. Returns owned ptr.
(self, xs, elem_w: TypeWrapper)
| 466 | return out |
| 467 | |
| 468 | def _py_to_lean_array(self, xs, elem_w: TypeWrapper) -> Any: |
| 469 | """Build a Lean Array from a Python iterable. Returns owned ptr.""" |
| 470 | items = list(xs) |
| 471 | arr = self.ffi.lean_alloc_array(len(items), len(items)) |
| 472 | # arr's m_data[i] holds owned pointers. |
| 473 | for i, x in enumerate(items): |
| 474 | child = elem_w.to_lean(x) |
| 475 | # Use lean_array_set_core (sets without bumping refcounts). |
| 476 | self.ffi.lean_array_set_core(arr, i, child) |
| 477 | return arr |
| 478 | |
| 479 | def _ctor_field_layout(self, ctor: CtorInfo): |
| 480 | """Compute the ABI memory layout for a constructor's fields. |