# coveragepy Status

Last updated: 2026-04-21

## Current state

E2E testing complete. Pipeline fixes shipped. Optimization targets identified but not yet benchmarked. Coveragepy work paused in favor of codeflash-api rewrite.

## Target repo

`~/Desktop/work/coveragepy_org/coveragepy`

Working tree has `[tool.codeflash]` config in pyproject.toml (unstaged). Manual AST-reuse optimizations stashed (`git stash list` — "manual ast-reuse optimizations and codeflash config").

## PRs

None yet.

## Key findings

- **Hot path**: PyTracer._trace() called on every line/call/return event
- **Data persistence**: numbits encoding uses zip_longest generators, add_lines/add_arcs do per-file SQL round-trips
- **Quick wins**: numbits_union() optimization, format_lines, substitute_variables
- **Parser**: PythonParser does multi-pass source text analysis with repeated text.count("\n") calls
- **E2E validated**: numbits_to_nums optimized (4.4% speedup, 24 tests), format_lines optimized (1.9% speedup, repair fixed 1 broken candidate out of 51 diffs)

## VM

Not provisioned. Pure Python — local benchmarking sufficient.

## Next steps

1. Resume coveragepy optimizations after codeflash-api rewrite starts
2. Top 10 targets identified (see session audit): numbits_to_nums, add_lines, add_arcs, lines_matching, exit_counts, contexts_by_lineno, source_token_lines, process_body, with_jump_fixers
3. Benchmark with coverage's own test suite as workload

## Blockers

None.
