OptiScan Engine
High-precision static analysis for Python — catching silent O(n²) performance bottlenecks with LibCST and generating deterministic JSON reports for autonomous AI refactoring agents.
0%False Positives
120Files/sec
11Detection Rules
v3.0Version
TL;DR — Quick Summary
- Targets silent performance killers in Python (O(n²) string concatenation, N+1 I/O inside loops, repeated attribute lookups).
- Built on LibCST (Concrete Syntax Tree) preserving comments and formatting for lossless diffs.
- Three-Layer Filtering System (name heuristics, scope initialisation tracking, RHS type inference) cuts false positives from 100% (V1) to 0% (V3).
- Multiprocessing via ProcessPoolExecutor analyses 120+ files/second with deterministic line metadata for AI agents.
Three-Layer Filter & Rule Catalog
Layer 1 — Name Heuristics
Filters 30+ counter patterns (cnt, total, idx) to avoid numeric false alarms.
Layer 2 — Init Tracking
Tracks first assignment in scope to distinguish integer accumulators from string builders.
Layer 3 — RHS Type Inference
Confirms string concatenation only when string literals, f-strings, or str() are observed.
| Rule ID | Tier | Pattern Detected | Impact |
|---|---|---|---|
PY-BOTTLENECK-201 | Critical | N+1 query / data-loading inside loops | Eliminates 100–10,000+ redundant I/O calls |
PY-BOTTLENECK-202 | Critical | O(n²) nested membership & iteration | Reduces complexity to O(n) / O(n log n) |
PY-PERF-001 | Auto-Fix | String concatenation in loops (+=) | O(n²) → O(n) via str.join() |
PY-PERF-002 | Auto-Fix | Inefficient x in dict.keys() | Direct O(1) dictionary key lookup |
PY-ARCH-103 | Architectural | Unbatched open() / write() in loops | 10–1,000x syscall reduction |
PY-ARCH-104 | Architectural | Large eager lists convertible to generators | 90%+ memory footprint reduction |