python-performance-optimization
cProfile、メモリプロファイラー、パフォーマンスベストプラクティスを使用してPythonコードをプロファイルおよび最適化。低速なPythonコードのデバッグ、ボトルネックの最適化、アプリケーションパフォーマンスの改善時に使用。
Security Assessment
About python-performance-optimization
The 'python-performance-optimization' skill is designed to help developers profile and optimize Python code using various profiling techniques. It provides tools for debugging slow Python code, identifying performance bottlenecks, and improving application performance. By using popular profiling tools like cProfile, memory profilers, and adhering to performance best practices, this skill targets areas where Python applications can become slow, such as CPU-heavy tasks, memory consumption issues, and inefficient I/O operations. The skill provides an effective way to analyze Python code and optimize it for better performance in production environments.
This skill offers a comprehensive approach to Python performance optimization, including CPU profiling to identify time-consuming functions, memory profiling to track memory allocation and leaks, and line profiling for detailed function-level insights. Additionally, it guides developers in improving code through algorithmic optimizations, parallelization, and caching. It also suggests using native extensions for critical paths, such as leveraging C or Rust for performance-critical operations. The toolset supports a wide range of use cases, from general application optimization to specific enhancements in database query performance and data processing pipelines.
Target users include Python developers looking to improve the performance of their applications, particularly those working on CPU-intensive tasks, large-scale data processing, or those dealing with memory optimization. It is especially useful for debugging performance issues in production environments and for developers seeking to implement high-performance algorithms or optimize existing code for better scalability and efficiency.
FAQ
What profiling tools are supported by this skill?
This skill supports profiling tools like cProfile for CPU profiling, memory_profiler for memory usage analysis, and line_profiler for line-by-line profiling. It also supports py-spy for profiling running Python processes in production.
Can I use this skill in a production environment?
Yes, py-spy can be used in production environments to profile running Python processes without affecting the performance of the application. It's suitable for diagnosing performance issues in live systems.
Do I need to install any external libraries to use the profiling tools?
Yes, some profiling tools such as line-profiler and memory-profiler need to be installed via pip before use. For py-spy, it needs to be installed separately as it is an external tool for profiling running processes.
Can this skill help with database query performance?
Yes, one of the use cases of this skill is optimizing database query performance. By profiling the Python code that interacts with the database, developers can identify and optimize inefficient queries or database interaction patterns.
Is there a way to profile memory usage in a more granular way?
Yes, using memory_profiler and line_profiler, you can track memory usage at a function or even line level, helping to identify specific areas where memory consumption can be reduced.
Install python-performance-optimization
Quick Setup:
- Copy the skill folder to
.claude/skills/ - Claude will automatically detect and use the skill
Repository
amurata/cc-tools