You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+11-12Lines changed: 11 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# numba cfunc compiler
2
2
3
-
Generic, framework-agnostic infrastructure for compiling Python functions to Numba @cfunc via AST transformation
3
+
Extensible compiler for producing native C-callable functions from Python source with stateful variables, typed containers, and pluggable type systems built on Numba @cfunc
@@ -9,15 +9,14 @@ Generic, framework-agnostic infrastructure for compiling Python functions to Num
9
9
10
10
## Overview
11
11
12
-
Generic, framework-agnostic infrastructure for compiling Python functions to Numba `@cfunc`via AST transformation. All domain-specific behavior is injected through registration APIs.
12
+
A compilation framework that transforms Python functions into native C-callable functions using Numba `@cfunc`and AST rewriting. Unlike using `@cfunc` directly, it provides:
13
13
14
-
The distribution is published as `numba-cfunc-compiler` and imported in Python as `numba_cfunc_compiler`.
15
-
16
-
This package is intended for applications that need to:
14
+
-**Stateful variables** — declare persistent state with natural syntax that survives across calls with automatic lifecycle management (start/execute/stop)
15
+
-**Standalone typed containers** — lists and dicts that work inside compiled functions without Numba's runtime overhead
16
+
-**Extensible type resolution** — register custom types that map Python syntax to numba-compatible lowering
17
+
-**Plugin architecture** — all domain-specific behavior (input handlers, output handlers, AST transforms, type inference) is injected through registration APIs
17
18
18
-
- transform Python functions into fixed-signature Numba entry points
19
-
- inject domain-specific typing, AST lowering, and runtime behavior through registrations
20
-
- ship a small native runtime alongside the Python package
19
+
The distribution is published as `numba-cfunc-compiler` and imported in Python as `numba_cfunc_compiler`.
21
20
22
21
## Installation
23
22
@@ -301,8 +300,8 @@ Registered by `defaults.register_all()`:
301
300
-**Primitives** — `int` (int64), `float` (float64), `bool` (int8). Support `State[int]`, etc.
302
301
-**DateTime** — Stored as nanoseconds (int64). Constructor calls like `datetime(2020,1,1,tzinfo=timezone.utc)` are lowered to constants at compile time. Must be timezone-aware.
303
302
-**TimeDelta** — Stored as nanoseconds (int64). `timedelta(seconds=5)` lowered to constants.
304
-
-**NumbaList** — NRT-free typed list (`int`/`float`/`bool` elements). Supports `len`, indexing, `append`, `pop`, `clear`, iteration. Created with `create_new_list(int)`.
-**Structs** — Opaque void pointers with field metadata. Read/write fields via pointer arithmetic. Base `StructType` must be subclassed with `is_type_supported()`, `_get_struct_fields()`, `_get_struct_size()`.
@@ -323,7 +322,7 @@ result = create_compiled_func(func, *args, options=opts, ...)
323
322
324
323
**`fastmath`***(compilation)* — Passes `fastmath=True` to the Numba `@cfunc` decorator, enabling aggressive floating-point optimizations (reassociation, no-NaN, etc.).
325
324
326
-
**`force_inline`***(post-compilation)* — Replaces Numba's `noinline` attribute on the cfunc wrapper → native call with `alwaysinline`, letting the LLVM optimizer merge them. Safe with `error_model='numpy'`and `_nrt=False`.
325
+
**`force_inline`***(post-compilation)* — Replaces Numba's `noinline` attribute on the cfunc wrapper with `alwaysinline`, letting the LLVM optimizer inline the function body into the wrapper and eliminate the extra call.
327
326
328
327
Regardless of options, the exported wrapper symbol is renamed to `_gc_numba_<semantic_key>`. `result.native_name`, `result.semantic_key`, and `result.llvm_ir` all reflect that final compiled form.
`NumbaList` and `NumbaDict` use standalone C implementations (`numba_rt/_py_nrt_init.so`) instead of Numba's reference-counted runtime. Memory is owned by the host framework via state slots. The C library is loaded lazily on first compilation via `CompilationContext.ensure_nrt_loaded()`.
0 commit comments