Claude prompt to optimize Python code performance
An official Anthropic example system prompt that asks Claude to suggest performance optimizations for Python code.
- Model
- Claude
- Task
- Coding
- Source
- Official example from Anthropic
The prompt tells Claude to analyze a Python snippet, find where it can be faster, more efficient or less resource-intensive, and explain each suggested change, while the optimized code keeps the same functionality. It is the system prompt of the Code consultant entry in Anthropic’s prompt library, where the code to analyze goes in the user message. To adapt it, keep it as the system prompt and send your own code.
The prompt is quoted from Code consultant - Claude API Docs.
- Prompt
- Your task is to analyze the provided Python code snippet and suggest improvements to optimize its performance. Identify areas where the code can be made more efficient, faster, or less resource-intensive. Provide specific suggestions for optimization, along with explanations of how these changes can enhance the code's performance. The optimized code should maintain the same functionality as the original code while demonstrating improved efficiency.
- What it produces
- Asks Claude, as a system prompt, to review Python code and suggest performance optimizations with explanations.
- Source link
- platform.claude.com
- Added
Questions
Where does my code go?
Will the optimized code behave the same?
Where does this prompt come from?
See also
Sources: each prompt is quoted from the official example or the public post linked on its page. Promptline is not affiliated with OpenAI, Anthropic, Google or Midjourney.
