Skip to content

Python Performance Optimization

Profile slow Python code and suggest targeted speed and memory fixes

Repository
wshobson/agents
Stars
42,095
Licence
MIT
Files
3 files

What it does

When installed, the agent gets a guide for finding why Python code is slow or memory-hungry. It knows to measure first with profiling tools such as cProfile and memory profilers, then suggests fixes like better data structures, caching, batching I/O, or NumPy. It is mainly a set of instructions and examples the agent follows while helping you, not a tool that changes your code on its own.

Great for

  • Python developers debugging slow scripts or web services
  • Engineers investigating memory growth or latency bottlenecks
  • Teams wanting a checklist of common Python performance pitfalls

Skip it if

  • Non-programmers, since the advice assumes working Python code and profiler output
  • Projects in other languages, because the guidance is Python-specific
  • Production systems to be profiled without care, since profiling live code can add overhead and the skill's own advice to profile production code (e.g. with py-spy) should be done deliberately

Try asking

  • “My Python data pipeline takes 20 minutes. Help me find the bottleneck with cProfile.”
  • “This Flask endpoint is slow under load, what should I check first?”
  • “Our Python worker's memory keeps growing. Help me track down the leak.”
  • “Suggest ways to speed up this loop that processes a million rows.”
Step-by-step guide: how to use Python Performance OptimizationInstall, first run, examples, tips and FAQs

Install in 3 steps

  1. 1

    Download the skill

    The ZIP contains the 3 original files, the MIT licence and an attribution note.

    python-performance-optimization.zip
  2. 2

    Add it to your agent

    Claude Code (all projects)

    mkdir -p ~/.claude/skills && unzip python-performance-optimization.zip -d ~/.claude/skills/

    Claude Code / Agent SDK (this project only)

    mkdir -p .claude/skills && unzip python-performance-optimization.zip -d .claude/skills/

    Claude apps (web/desktop): Settings → Capabilities → Skills → Upload skill, and choose the ZIP.

  3. 3

    Ask for the task

    No special command needed — the agent reads the skill's description and loads it when your request matches. Try one of the prompts above.

Get better results

  • Give the agent real profiler output or a reproducible slow case so it can measure rather than guess.
  • Ask for one change at a time and re-measure to confirm each optimization helps.
  • Review any suggested code before running it against production data or systems.

What's inside

  • references/advanced-patterns.md
  • references/details.md
  • SKILL.md

Redistributed unmodified from wshobson/agents under the MIT licence. The assessment was drafted with AI from the skill's files on 2026-10-29. Skills can instruct your agent to run code — read SKILL.md and any scripts before installing.