porwshobson·wshobson· v1.0.0 · atualizado em 2026-04-10
82
Score
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.
Profile the code: — Use tools like `cProfile`, `line_profiler`, or `memory_profiler` to identify performance bottlenecks.
2
Analyze the results: — Examine the profiling output to pinpoint slow functions, memory leaks, or inefficient code patterns.
3
Apply optimization techniques: — Implement strategies like list comprehensions, generator expressions, dictionary lookups, or NumPy for numerical operations.
4
Benchmark the changes: — Measure the performance improvement using `timeit` or `pytest-benchmark`.
5
Iterate: — Repeat the profiling and optimization process until the desired performance is achieved.
6
Test: — Ensure the changes haven't introduced any regressions.