python-performance

Profile Python code with cProfile and generate performance reports.

Updated Jul 10, 2026
One-click install
npx skills add https://github.com/gookeryoung/coopie --skill python-performance-gookeryoung
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: python-performance
Source: https://github.com/gookeryoung/coopie/tree/main/.trae/skills/python-performance
Command: npx skills add https://github.com/gookeryoung/coopie --skill python-performance-gookeryoung

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires pytest-benchmark, pyinstrument, line_profiler, memray, snakeviz.

What problem does it solve?

This skill addresses the challenge of identifying and resolving performance bottlenecks in Python applications, moving from guesswork to data-backed optimization.

Core Features & Use Cases

  • Performance Benchmarking: Establish reliable baselines using high-precision timers and pytest-benchmark.
  • Hotspot Analysis: Identify CPU and memory bottlenecks using cProfile, py-spy, and memray.
  • Optimization Patterns: Apply proven techniques like algorithmic complexity reduction, caching, and efficient I/O handling.
  • Use Case: When a production service experiences latency spikes, use this skill to profile the execution path, identify the specific function causing the delay, and implement a targeted optimization.

Quick Start

Use the python-performance skill to profile the execution of the main function in my_script.py and generate a performance report.

Frequently Asked Questions about python-performance

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I identify CPU hotspots and memory leaks in a Python application?

Identify CPU hotspots and memory leaks by profiling the Python execution path with tools like cProfile and memray. This skill analyzes memory usage and pinpoints specific functions causing latency spikes or excessive resource consumption.

What is the best way to establish reliable performance benchmarks for Python functions?

Establish reliable performance benchmarks for Python functions using high-precision timers and pytest-benchmark. This skill creates data-backed baselines to measure execution time accurately and detect performance regressions during development.

Can I integrate Python performance profiling and regression testing into a CI/CD pipeline?

Yes, you can integrate Python performance profiling into CI/CD pipelines using pytest-benchmark. This skill supports performance regression testing to ensure new code changes do not degrade application latency or efficiency.

How do I analyze execution time and optimize algorithmic complexity in Python code?

Analyze execution time and optimize algorithmic complexity in Python by applying proven techniques like caching and efficient I/O handling. This skill uses systematic profiling data to guide targeted algorithmic refinement and complexity reduction.

Does this approach work with line-by-line profiling and visualization tools like line_profiler and snakeviz?

Yes, this approach works with line_profiler and snakeviz to provide detailed execution time analysis and visualizations. These dependencies help identify exact lines of Python code that cause performance bottlenecks and require optimization.

When should I use pyinstrument instead of cProfile for Python optimization?

Use pyinstrument for low-overhead statistical profiling of Python execution, whereas cProfile provides deterministic function-level timings. This skill leverages both to profile execution paths and identify CPU bottlenecks based on your specific optimization needs.