协作头脑风暴
brainstorming
在实现前澄清需求、探索设计选择,并形成清晰的开发方向。
python-performance【开发与工程】Profiles Python code for performance bottlenecks and memory issues. Use when Python code is slow or when profiling for optimization before a release.
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
name: python-performance description: Profiles Python code for performance bottlenecks and memory issues. Use when Python code is slow or when profiling for optimization before a release. globs: "**/*.py" alwaysApply: false category: performance tags:
Profiling and optimization patterns for Python code.
# Basic timing
import timeit
time = timeit.timeit("sum(range(1000000))", number=100)
print(f"Average: {time / 100:.6f}s")
Verification: Run the command with --help flag to verify availability.
This skill is organized into focused modules for progressive loading:
CPU profiling with cProfile, line profiling, memory profiling, and production profiling with py-spy. Essential for identifying where your code spends time and memory.
Eleven proven optimization patterns including list comprehensions, generators, caching, string concatenation, data structures, NumPy, multiprocessing, database operations, and loop transformations (what works in Python vs the compiler).
Memory optimization techniques including leak tracking with tracemalloc and weak references for caches. Depends on profiling-tools.
Benchmarking tools including custom decorators and pytest-benchmark for verifying performance improvements.
Best practices, common pitfalls, and exit criteria for performance optimization work. Synthesizes guidance from profiling-tools and optimization-patterns.