Claude Marketplaces
SkillsMCP serversMarketplacesDigestTools
Submit

This week in Claude

Every Monday: Claude Code, Agent SDK, MCP, and the Anthropic platform moves worth your time.

Skills by category
Frontend DevelopmentBackend & APIsTesting & QASecurityDevOps & CI/CDGit & Pull RequestsDocumentationCode Review & QualityAI & Agent BuildingSkill Development
MCP servers by category
Sales & MarketingWeb & Browser AutomationDatabasesAI & LLM ToolsCloud & InfrastructureCommunication & MessagingDeveloper ToolsDesign & CreativeDocuments & KnowledgeSearch & Web Crawling
Marketplaces by category
AI Agents & OrchestrationLLM IntegrationDevelopment ToolsFrontend & UIBackend & APIsDatabasesTesting & Code QualityDevOps & CloudSecurity & ComplianceGit & Version Control
Claude Marketplaces

An independent directory of skills, plugins and MCP servers for Claude Code. Not affiliated with Anthropic.

Browse

  • Skills
  • MCP servers
  • Marketplaces
  • Weekly digest
  • Skill index
  • MCP index
  • Marketplace index

Site

  • About
  • Tools
  • Submit
  • Feedback
  • Privacy
  • llms.txt
  • Plugins reference

Maker

  • Snug
  • Agent Caffeine
  • knobs
  • Wax
  • Vectoys
  • mertduzgun.com
Crafted at
Skills/Debugging
wshobson avatar

Python Performance Optimization

wshobson/agents

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.

installs
35.9K
GitHub stars
41.8K
last updated
Aug 21, 2026
View on GitHubSave

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

  • Algorithmic: Better algorithms and data structures
  • Implementation: More efficient code patterns
  • Parallelization: Multi-threading/processing
  • Caching: Avoid redundant computation
  • Native Extensions: C/Rust for critical paths

Quick Start

Basic Timing

import time

def measure_time():
    """Simple timing measurement."""
    start = time.time()

    # Your code here
    result = sum(range(1000000))

    elapsed = time.time() - start
    print(f"Execution time: {elapsed:.4f} seconds")
    return result

# Better: use timeit for accurate measurements
import timeit

execution_time = timeit.timeit(
    "sum(range(1000000))",
    number=100
)
print(f"Average time: {execution_time/100:.6f} seconds")

Detailed patterns and worked examples

Detailed pattern documentation lives in references/details.md. Read that file when the navigation tier above is insufficient.

Best Practices

  1. Profile before optimizing - Measure to find real bottlenecks
  2. Focus on hot paths - Optimize code that runs most frequently
  3. Use appropriate data structures - Dict for lookups, set for membership
  4. Avoid premature optimization - Clarity first, then optimize
  5. Use built-in functions - They're implemented in C
  6. Cache expensive computations - Use lru_cache
  7. Batch I/O operations - Reduce system calls
  8. Use generators for large datasets
  9. Consider NumPy for numerical operations
  10. Profile production code - Use py-spy for live systems

Common Pitfalls

  • Optimizing without profiling
  • Using global variables unnecessarily
  • Not using appropriate data structures
  • Creating unnecessary copies of data
  • Not using connection pooling for databases
  • Ignoring algorithmic complexity
  • Over-optimizing rare code paths
  • Not considering memory usage

Sponsors

SnugThe clipboard manager you and your agent can use, safelyAgent CaffeineClose your lid, come back to finished workWaxBlock anything with supervision, without erasing your iPhoneOpen StepsSponsoredFree and open-source skills that make AI coding agents easier to understand, verify, and control.

Details

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

More from wshobson/agents

All 174
  • Nextjs App Router Patterns32.7K
  • Api Design Principles30.5K
  • Code Review Excellence30.3K
  • Postgresql Table Design28K
  • Fastapi Templates26K
  • Security Requirement Extraction25.2K
  • Mobile Android Design25.1K
  • E2e Testing Patterns24.5K
  • Architecture Patterns24.3K
  • Mobile Ios Design23.8K
  • Prompt Engineering Patterns23.6K
  • Error Handling Patterns23.1K
  • Python Design Patterns23K
  • Architecture Decision Records22.5K
  • Modern Javascript Patterns21.7K
  • Responsive Design21.1K
  • Stride Analysis Patterns20.9K
  • Rust Async Patterns20.8K
  • Javascript Testing Patterns20.6K
  • Sql Optimization Patterns19.9K
  • Threat Mitigation Mapping19.9K
  • Auth Implementation Patterns19.7K
  • Git Advanced Workflows19.5K
  • Dotnet Backend Patterns19.2K

Recommended

More Debugging
1ibelick avatarfixing-motion-performanceibelick/ui-skillsAudit and fix animation performance issues including layout thrashing, compositor properties, scroll-linked motion, and blur effects. Use when animations stutte27Kinstalls
2software-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, 26.6Kinstalls
3wshobson avatarpython-error-handlingwshobson/agentsPython error handling patterns including input validation, exception hierarchies, and partial failure handling. Use when implementing validation logic, designin14.2Kinstalls
4hyf0 avatarvue-debug-guideshyf0/vue-skillsComprehensive Vue 3 debugging reference covering reactivity, components, templates, lifecycle, SSR, and 100+ common runtime issues.14.2Kinstalls
5openai 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.5Kinstalls
6wshobson avatarparallel-debuggingwshobson/agentsDebug complex issues using competing hypotheses with parallel investigation, evidence collection, and root cause arbitration. Use this skill when debugging bugs10.1Kinstalls