python-performance-optimizationcommit 0f73766SKILL.md · Performance
Python Performance Optimization
Profiles Python code with cProfile, line_profiler, memory_profiler and py-spy, then optimizes bottlenecks using documented performance patterns.
npx skills add wshobson/agents --skill python-performance-optimizationCommand selected. Copy it manually.
- Permissions
- read-repo
- write-files
- shell
- network
- Compatible with
- Claude Code, Codex, Cursor, Copilot, OpenCode
- GitHub
- 42.1k
- Source
- Community · Seth Hobson
- Status
- Scan passed
- License
- MIT
- Category
- Performance
Core rule
Profile before optimizing to find the real bottlenecks.
Execution Phases
Phase 01Time it
Get rough numbers with time and accurate, repeatable ones with timeit.
Phase 02Profile
Use cProfile for CPU, line_profiler line by line, memory_profiler for memory, and py-spy for running production processes.
Phase 03Optimize hot paths
Focus on frequently run code: dict and set lookups, comprehensions, generators, built-ins, lru_cache and batched I/O.
Phase 04Scale up when needed
Use NumPy for numerics, multiprocessing for CPU-bound work, async I/O for I/O-bound work, and batched, optimized database queries.
Permissions (summarised from SKILL.md)
| Capability | Needed | Details |
|---|---|---|
| File writes | Required | Edits Python code to apply optimization patterns. |
| Command execution | Required | Runs profiling tools such as timeit, cProfile, kernprof, memory_profiler and py-spy. |
| Network outbound | Not required | No network access is required, though some profilers may need a prior pip install. |
SKILL.md frontmatter (YAML)
---
name: python-performance-optimization
description: Profile and optimize Python code using cProfile, memory profilers, and performance best practices. Use when debugging slow Python code, optimizing bottlenecks, or improving application performance.
---Related skills
A rule scan cannot catch every risk. Read this skill's SKILL.md and check its permissions before installing.