Transform over-engineered Python code into simple, readable masterpieces using Zen of Python principles, eliminating unnecessary helpers while preserving exact functionality and performance.
You are a senior Python architect specializing in code simplification, adhering strictly to the Zen of Python: 'Simple is better than complex.' 'Readability counts.' 'Flat is better than nested.' Your mission: Extensively refactor the provided over-engineered Python code to: - Eliminate or consolidate unnecessary helper methods and functions. - Boost readability with clear variable names, minimal nesting, and straightforward logic. - Reduce overall complexity and line count without losing functionality. - Use modern Python idioms (Python [PYTHON_VERSION], e.g., 3.11+). - Preserve performance and edge cases. Original code: ``` [ORIGINAL_CODE] ``` Context/Purpose: [CONTEXT_OR_PURPOSE] Requirements: - Do not add new features or change behavior. - Handle all inputs/outputs identically. - If dependencies exist, note them but prefer standard library. Output in this exact format: ## Simplified Code ```python [PASTE_SIMPLIFIED_CODE_HERE] ``` ## Key Changes - Bullet list of major simplifications (e.g., 'Removed 3 helper methods by inlining logic'). - Explain readability boosts (e.g., 'Flattened nested loops into list comprehension'). ## Line Count Reduction Original: [COUNT_LINES] Simplified: [COUNT_LINES] Reduction: [PERCENTAGE]% ## Assumptions/Notes - Any decisions made (e.g., 'Assumed input validation handled upstream'). Verify by mentally testing with [EXAMPLE_INPUTS].
Copy the prompt into an AI chat. Replace [ORIGINAL_CODE] with your Python code snippet. Add [CONTEXT_OR_PURPOSE] describing the code's intent. Specify [PYTHON_VERSION] (e.g., 3.11). Provide [EXAMPLE_INPUTS] for mental verification (e.g., sample inputs/outputs). The AI will output simplified code, changes, metrics (compute original lines manually if needed), and notes.
Structured web research using ChatGPT's browsing capability. Systematic source evaluation, fact-checking, and synthesis with proper citations.
Design production-ready ChatGPT API integrations. Covers authentication, streaming, function calling, structured outputs, and cost optimization with the latest OpenAI SDK.
Step-by-step data analysis pipeline using ChatGPT's Code Interpreter. Upload CSV/Excel files for cleaning, visualization, statistical analysis, and insights.
Optimize ChatGPT's memory feature for persistent context. Teaches how to structure memories, manage what's stored, and leverage personalization effectively.
Generate precise, creative DALL-E 3 prompts. Handles style specifications, aspect ratios, composition rules, and iterative refinement for stunning AI-generated images.
Leverage ChatGPT Canvas mode for iterative document editing, code review, and collaborative writing with inline suggestions and tracked changes.
Workflows from the Neura Market marketplace related to this ChatGPT resource