Near Zero-Overhead Python Code Coverage
summary
Coverage.py can slow tests up to 2.6x; SlipCover claims near-zero overhead by instrumenting bytecode and inserting tiny native C probes that record a line once, batch instrumentation, and de‑instrument hot paths when counters cross a threshold. Result: roughly 5% overhead for line+branch coverage on CPython and about 31% on PyPy, supports Python 3.12 via the Low Impact Monitoring API (PEP669), and maps branches using phantom source lines to preserve familiar metrics.
AI-written summary · about
chapters (7)
- 0:00Understanding code coverage
- 2:52Introducing SlipCover
- 4:27Optimization techniques
- 7:38Evolution of SlipCover
- 11:43Leveraging sys.monitoring
- 15:20Implementing branch coverage
- 20:43Future directions and summary
related talks
12mDelete all code! 100% testing coverage, the lazy way!
37mTuning Python applications can dramatically increase performance
01h 03mA tour of CPython's runtime
57mPython and PyPy performance (not) for dummies
22mPyPy in production
33mWhy is Python slow?
22mPyPy and the future of the Python ecosystem
27mDon't Make Me Laugh, My Coverage
