py-perf

Profile and optimize Python application performance with cProfile, Pyinstrument, and Memray.

1|1|Updated Mar 28, 2026
One-click install
npx skills add https://github.com/stevenke1981/python_skills --skill py-perf
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: py-perf
Source: https://github.com/stevenke1981/python_skills/tree/main/py-perf
Command: npx skills add https://github.com/stevenke1981/python_skills --skill py-perf

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires py-spy, pyinstrument, line_profiler, memory_profiler, and includes references (resource) components.

What problem does it solve?

This Skill addresses performance regressions, high memory usage, and latency issues by providing a structured, data-driven approach to profiling and optimizing Python applications.

Core Features & Use Cases

  • Performance Profiling: Identify CPU and memory hotspots using industry-standard tools like cProfile, Pyinstrument, and Memray.
  • Benchmark Validation: Establish reproducible baselines and regression gates to ensure optimizations provide measurable, stable improvements.
  • Use Case: When a production API experiences latency spikes, use this Skill to attach a profiler, isolate the bottleneck in the request-handling loop, and verify the fix with a controlled benchmark.

Quick Start

Use the py-perf skill to profile the execution of the main function in app.py and generate a flame graph to identify performance bottlenecks.

Frequently Asked Questions about py-perf

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

FAQPage Schema
How do I diagnose Python performance bottlenecks and high memory usage?

Diagnose Python performance bottlenecks by systematically profiling CPU and memory hotspots using tools like py-spy and memory_profiler. This Skill attaches a profiler to isolate latency issues in request-handling loops and identify resource-intensive code paths.

How do I benchmark Python code to prevent performance regressions?

Benchmark Python code by establishing reproducible baselines and regression gates that validate optimizations. This Skill ensures performance testing provides measurable, stable improvements and prevents regressions across various Python environments.

Does this Skill support profiling I/O-heavy and CPU-bound workloads?

Yes, it supports profiling I/O-heavy and CPU-bound workloads across various Python environments. The Skill performs systematic profiling and algorithmic analysis to measure and optimize application performance for these specific workload types.

What is the best way to profile a Python application experiencing latency spikes?

The best way to profile a Python application with latency spikes is attaching a profiler to isolate the bottleneck in the request-handling loop. Use pyinstrument or line_profiler to generate flame graphs and verify the fix with a controlled benchmark.

Can I use py-spy and pyinstrument to generate flame graphs for Python profiling?

Yes, you can use py-spy and pyinstrument to profile the execution of functions and generate flame graphs. This Skill leverages these dependencies to identify CPU performance bottlenecks and visualize resource consumption effectively.

Why does my Python application have high memory usage after optimization?

High memory usage persists when optimizations lack measurable validation against reproducible baselines. Profile memory hotspots using memory_profiler to isolate intensive allocations, then verify the fix with controlled benchmarking to ensure stable resource consumption.