Context Managers API Reference
Context managers for block-level optimization control.
optimize_context()
Apply optimization to a code block.
Signature
with epochly.optimize_context(level=None):# optimized code
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
level | int | None | Enhancement level (0-4) |
Example
import epochlywith epochly.optimize_context(level=3):result = heavy_computation(data)
monitoring_context()
Add performance monitoring to a code block.
Signature
with epochly.monitoring_context(name=None):# monitored code
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
name | str | None | Name for metrics grouping |
jit_context()
Enable JIT compilation for a code block.
Signature
with epochly.jit_context(backend='auto'):# JIT-compiled code
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
backend | str | 'auto' | JIT backend |
threading_context()
Enable threading optimization for a code block.
Signature
with epochly.threading_context(max_workers=None):# threaded code
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
max_workers | int | None | Maximum thread count |
benchmark_context()
Benchmark a code block.
Signature
with epochly.benchmark_context(iterations=100) as benchmark:# code to benchmarkprint(benchmark.results)
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
iterations | int | 100 | Number of iterations |
warmup | int | 10 | Warmup iterations |