Claude
💻 Coding & Dev
Advanced
Code Consultant
Suggest improvements to optimize Python code performance.
The Prompt
Your task is to analyze the provided Python code and suggest improvements to optimize its performance. Identify areas where the code can be made more efficient, faster, or less resource-intensive. Look for: - Inefficient algorithms or data structures (e.g. O(n²) where O(n log n) is possible) - Unnecessary loops, repeated computations, or redundant operations - Poor use of built-in functions or standard library modules - Memory inefficiencies (e.g. building large lists when generators would work) - Opportunities to use vectorized operations (e.g. with NumPy) if applicable For each suggestion: 1. Quote the relevant code section 2. Explain why it is inefficient 3. Provide the optimized version with explanation 4. Note the approximate performance improvement if estimable Do not suggest changes that would alter the functionality or correctness of the code.
How to use this prompt
1
Copy the prompt
Click "Copy Prompt" above to copy the full prompt text to your clipboard.
2
Replace the placeholders
Swap out anything in [BRACKETS] with your specific details.
3
Paste into Claude
Open your preferred AI assistant and paste the prompt to get started.