Skip to content

Commit fd7e2c0

Browse files
committed
perf: add --version fast-path to skip full import chain
When the user runs `codeflash --version`, read the version string and exit immediately without importing cli, telemetry, models, or any other heavy modules. This mirrors the pattern used in pip where `pip --version` was optimized from 138ms to 20ms (7x). Before: 524ms (imports cli.py -> cfapi -> models -> libcst -> ...) After: ~16ms (imports only codeflash.version)
1 parent 6f3f884 commit fd7e2c0

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

codeflash/main.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@
2222

2323
def main() -> None:
2424
"""Entry point for the codeflash command-line interface."""
25+
# Fast path: --version exits before importing the full stack
26+
if len(sys.argv) == 2 and sys.argv[1] == "--version":
27+
from codeflash.version import __version__
28+
29+
print(f"Codeflash version {__version__}")
30+
return
31+
2532
from pathlib import Path
2633

2734
from codeflash.cli_cmds.cli import parse_args, process_pyproject_config

0 commit comments

Comments
 (0)