Collections and generics¶
Li mirrors Python 3.14 collection typing where possible, compiled to native layouts.
list[T]¶
Dynamic length; allocation may raises Alloc.
dict[K, V]¶
Arity and key types are checked statically.
tuple and named tuples¶
Variadic tuples supported in tests (li-tests/collections/).
TypedDict¶
enum¶
Generics (PEP 695)¶
Type parameters in square brackets on def and type.
Protocol and Callable¶
Structural protocols (e.g. Sized) and function types for higher-order code.
Tests: li-tests/generics/.
Arrays vs lists¶
array[N, T] | list[T] | |
|---|---|---|
| Size | Fixed at compile time | Grows at runtime |
| Stack / inline | Often stack-allocated | Heap |
| HPC kernels | Preferred | Less common in hot paths |