wshobson avatar

Python Performance Optimization

This walks you through the essential Python profiling toolkit, from cProfile for CPU bottlenecks to memory_profiler for tracking allocations and py-spy for production debugging. You'll learn to identify slow functions, optimize list comprehensions versus loops, fix string concatenation performance, and choose the right data structures. The patterns cover real optimization wins like switching from O(n) list searches to O(1) dictionary lookups, using generators to reduce memory usage, and leveraging local variables over globals. Solid for debugging sluggish applications or optimizing data processing pipelines before they hit production.

install copies · 90 days. Times the install command was copied on this site in the last 90 days, bots filtered.
30
skills.sh installs
37.6K
GitHub stars
42.4K
last updated
Aug 21, 2026

Install

$ npx -y skills add wshobson/agents --skill python-performance-optimization --agent claude-code

Installs into .claude/skills of the current project.

Files

Python Performance Optimization

Comprehensive guide to profiling, analyzing, and optimizing Python code for better performance, including CPU profiling, memory optimization, and implementation best practices.

When to Use This Skill

  • Identifying performance bottlenecks in Python applications
  • Reducing application latency and response times
  • Optimizing CPU-intensive operations
  • Reducing memory consumption and memory leaks
  • Improving database query performance
  • Optimizing I/O operations
  • Speeding up data processing pipelines
  • Implementing high-performance algorithms
  • Profiling production applications

Core Concepts

1. Profiling Types

  • CPU Profiling: Identify time-consuming functions
  • Memory Profiling: Track memory allocation and leaks
  • Line Profiling: Profile at line-by-line granularity
  • Call Graph: Visualize function call relationships

2. Performance Metrics

  • Execution Time: How long operations take
  • Memory Usage: Peak and average memory consumption
  • CPU Utilization: Processor usage patterns
  • I/O Wait: Time spent on I/O operations

3. Optimization Strategies

Sponsors

Details

Repository
github.com/wshobson/agents
Categories
Debugging, Python

More from wshobson/agents

All 174

Recommended

More Debugging
1software-mansion avatarargent-metro-debuggersoftware-mansion/argentDebug a JS runtime via CDP using argent debugger tools. Primary path is React Native via Metro (iOS / Android / Vega); a subset of the tools (debugger-connect, 29.9Kskills.sh installs
2ibelick avatarfixing-motion-performanceibelick/ui-skillsAudit and fix animation performance issues including layout thrashing, compositor properties, scroll-linked motion, and blur effects. Use when animations stutte28.6Kskills.sh installs
3wshobson avatarpython-error-handlingwshobson/agentsPython error handling patterns including input validation, exception hierarchies, and partial failure handling. Use when implementing validation logic, designin14.7Kskills.sh installs
4openai avatargh-fix-ciopenai/skillsUse when a user asks to debug or fix failing GitHub PR checks that run in GitHub Actions; use `gh` to inspect checks and logs, summarize failure context, draft 11.8Kskills.sh installs
5getsentry avatarsentry-fix-issuesgetsentry/sentry-for-aiFind and fix issues from Sentry using MCP. Use when asked to fix Sentry errors, debug production issues, investigate exceptions, or resolve bugs reported in Sen10.4Kskills.sh installs
6wshobson avatarparallel-debuggingwshobson/agentsDebug complex issues using competing hypotheses with parallel investigation, evidence collection, and root cause arbitration. Use this skill when debugging bugs10.4Kskills.sh installs