#528 [API/Perf] Regex compilation in hot paths - multiple locations

closed medium Created 2025-12-17 15:00 · Updated 2025-12-17 15:54

Description

Edit
**Files:** - api/blueprints/v1/steps.py:377 - search regex compiled per-request - api/blueprints/v1/apps.py:69-70 - semver regex compiled per-call - api/blueprints/v1/apps.py:147 - app name validation regex per-call - api/blueprints/v1/workflows.py:81-86 - DSL main block regex per-call **Problem:** Regex patterns compiled on every request/call instead of module level. **Fix:** Move all regex to module level constants: ```python # Module level _SEMVER_PATTERN = re.compile(r"^(\d+)\.(\d+)\.(\d+)(?:-([a-zA-Z0-9]+))?$") _APP_NAME_PATTERN = re.compile(r"^[a-z][a-z0-9_]{2,63}$") _MAIN_BLOCK_PATTERN = re.compile(r"if\s+__name__\s*==\s*[\"']__main__[\"']\s*:.*", re.DOTALL) ``` **Impact:** 10-20% speedup for affected endpoints.

Comments

Loading comments...

Context

Loading context...

Audit History

View All
Loading audit history...