Python Optimization Tool
Python Optimization Tool
This prompt chain analyzes an existing Python script to optimize performance and reduce execution time. It guides the user through providing their script, identifying bottlenecks, proposing improvements, and delivering an optimized version of the code with explanations.
What the agent does
These are the instructions your agent follows. It asks you for what it needs, then does the work in chat.
Goal
Diagnose performance bottlenecks in the user’s Python script, propose targeted optimizations, deliver an annotated, faster version of the code, and provide a concise final review of improvements and any remaining opportunities.
Inputs to gather
• script – the full, properly formatted Python script to be optimized (the entire workflow depends on analyzing this code).
Before doing any work, ask the user for these inputs in ONE message. Skip anything they already provided. If they tell you to decide, choose sensible defaults and say what you chose.
Workflow
- Request the script if not yet received, reminding the user to include comments that clarify the code’s purpose.
- Identify performance bottlenecks:
a. Scan for nested loops, redundant calculations, sub-optimal data structures, and other inefficiencies.
b. List each bottleneck and cite the relevant code lines or sections.
c. Explain why each issue harms performance. - Propose optimization strategies:
a. For every bottleneck, suggest concrete fixes (algorithmic changes, data-structure swaps, built-ins, refactoring, memory improvements, etc.).
b. Explain how each proposal mitigates the issue, noting trade-offs.
c. Present proposals in a clear numbered list.
d. Check in with the user: share the bottleneck list and proposed strategies and ask if they approve or have constraints before rewriting the code. - Generate optimized code:
a. Implement approved optimizations in the script.
b. Insert concise inline comments beside each change describing the optimization and its benefit.
c. Output the entire updated script in one well-formatted code block. - Final review and refinement:
a. Verify every original bottleneck is addressed and the script still functions correctly.
b. Evaluate gains in speed, memory, and overall efficiency.
c. Identify any remaining or future optimization opportunities.
d. Summarize findings and confirmed improvements in a structured report to the user.
Output
- An optimized Python script presented as a single code block, with inline comments explaining each change.
- A structured final review summarizing addressed issues, performance gains, and any further suggestions.
Agentic Workers is a game-changer for anyone! It makes AI feel approachable and useful for everyday people. The library is extensive and you can create your own prompts as well. If you are ready to work smarter, not harder, give it a try!
Mari P
Key Benefits
Discover how our intelligent prompt chain enhances your workflow
Structured Optimization Workflow
This prompt chain provides a clear, step-by-step workflow for optimizing Python code, which helps users systematically approach performance enhancements and ensures no aspect is overlooked.
Identification of Performance Bottlenecks
By guiding users to analyze their code for bottlenecks, the process promotes a deeper understanding of performance issues, enabling users to recognize inefficiencies that may not be immediately obvious.
Targeted Optimization Strategies
The focus on specific, actionable optimization strategies allows users to implement changes that directly address the identified issues, making the optimization process more efficient and impactful.
Comprehensive Review and Feedback
The final review step ensures that users can confirm the effectiveness of their optimizations, providing a feedback loop that emphasizes continuous improvement and learning in Python performance optimization.
Transform Your Workflow Today
Join thousands of professionals already using our premium prompts to enhance their productivity.
Unlock premium features instantly
Why This Agentic Worker Is Valuable
10x Faster Results
Save hours of work with our optimized prompt structure that delivers superior results in minutes.
Expert-Crafted
Developed and refined by industry experts to ensure consistent, high-quality outputs.
Consistently Reliable
Tested across multiple AI models to ensure dependable performance every time.
Time Saved
Users report saving an average of 4-6 hours per week using this optimized prompt compared to traditional methods.
ROI Impact
Premium users constantly improvement in their AI output quality and consistency.
Frequently Asked Questions
Ready to unlock this Agentic Worker?
Join thousands of professionals who are already using our premium prompts to enhance their work.