Profile and optimize Python code using cProfile, memory profilers, and performance best practices. Use when debugging slow code, optimizing bottlenecks, or improving application performance.
Scanned 2/10/2026
Install via CLI
openskills install athola/claude-night-market---
name: python-performance
description: Profile and optimize Python code using cProfile, memory profilers, and performance best practices. Use when debugging slow code, optimizing bottlenecks, or improving application performance.
category: performance
tags: [python, performance, profiling, optimization, cProfile, memory]
tools: [profiler-runner, memory-analyzer, benchmark-suite]
usage_patterns:
- performance-analysis
- bottleneck-identification
- memory-optimization
- algorithm-optimization
complexity: intermediate
estimated_tokens: 1200
progressive_loading: true
modules:
- profiling-tools
- optimization-patterns
- memory-management
- benchmarking-tools
- best-practices
---
# Python Performance Optimization
Profiling and optimization patterns for Python code.
## Quick Start
```python
# Basic timing
import timeit
time = timeit.timeit("sum(range(1000000))", number=100)
print(f"Average: {time/100:.6f}s")
```
## When to Use
- Identifying performance bottlenecks
- Reducing application latency
- Optimizing CPU-intensive operations
- Reducing memory consumption
- Profiling production applications
- Improving database query performance
## Modules
This skill is organized into focused modules for progressive loading:
### [profiling-tools](modules/profiling-tools.md)
CPU profiling with cProfile, line profiling, memory profiling, and production profiling with py-spy. Essential for identifying where your code spends time and memory.
### [optimization-patterns](modules/optimization-patterns.md)
Ten proven optimization patterns including list comprehensions, generators, caching, string concatenation, data structures, NumPy, multiprocessing, and database operations.
### [memory-management](modules/memory-management.md)
Memory optimization techniques including leak tracking with tracemalloc and weak references for caches. Depends on profiling-tools.
### [benchmarking-tools](modules/benchmarking-tools.md)
Benchmarking tools including custom decorators and pytest-benchmark for verifying performance improvements.
### [best-practices](modules/best-practices.md)
Best practices, common pitfalls, and exit criteria for performance optimization work. Synthesizes guidance from profiling-tools and optimization-patterns.
## Exit Criteria
- Profiled code to identify bottlenecks
- Applied appropriate optimization patterns
- Verified improvements with benchmarks
- Memory usage acceptable
- No performance regressions
No comments yet. Be the first to comment!