Decorators API Reference
Function decorators for applying Epochly optimizations.
@optimize
Main optimization decorator. Applies progressive enhancement based on configured level.
Signature
@epochly.optimizedef function(args):...@epochly.optimize(level=3)def function(args):...@epochly.optimize(level=2, threshold=100)def function(args):...
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
level | int | None | Target enhancement level (0-4) |
threshold | int | 1000 | Calls before optimization kicks in |
monitor | bool | True | Enable performance monitoring |
Example
import epochly@epochly.optimizedef process_data(data):return [x ** 2 for x in data]@epochly.optimize(level=3)def heavy_computation(matrix):return matrix_multiply(matrix)
@performance_monitor
Add performance monitoring without optimization.
Signature
@epochly.performance_monitordef function(args):...@epochly.performance_monitor(detailed=True)def function(args):...
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
detailed | bool | False | Collect detailed metrics |
log_calls | bool | False | Log each function call |
@jit_compile
Force JIT compilation for numerical functions.
Signature
@epochly.jit_compiledef function(args):...@epochly.jit_compile(backend='numba', cache=True)def function(args):...
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
backend | str | 'auto' | JIT backend ('auto', 'numba', 'native') |
cache | bool | True | Cache compiled code |
parallel | bool | False | Enable parallel execution |
nopython | bool | True | Numba nopython mode |
@full_optimize
Apply maximum optimization (Level 3 or 4).
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
gpu | bool | False | Enable GPU if available |
workers | int | None | Number of workers |
@threading_optimize
Apply Level 1 threading optimization for I/O-bound functions.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
max_workers | int | None | Maximum thread count |