What problem does it solve? Python applications often suffer from hidden performance bottlenecks and memory leaks that are hard to locate without proper tooling. This Skill provides structured guidance for profiling CPU usage, analyzing memory allocation, benchmarking code, and applying proven optimization patterns. ## Core Features & Use Cases - CPU Profiling: Run scripts with PyInstrument for readable statistical output or cProfile for detailed cumulative timing. - Memory Analysis: Use memray and tracemalloc to detect memory leaks and inspect allocation hotspots line by line. - Benchmarking: Write regression-safe benchmarks with pytest-benchmark and compare results across runs. - Use Case: A data pipeline runs slower after a refactor. Profile it with PyInstrument to find the bottleneck function, apply an algorithmic fix such as replacing list membership checks with a set, then add a pytest-benchmark test to prevent regression. ## Quick Start Ask the AI to profile your slow Python script with PyInstrument and suggest optimizations for the top bottleneck functions.