Refactor Python code for clarity, performance, and Pythonic idioms. ## Steps 1. Read the target Python file or module. 2. Identify refactoring opportunities: 3. Apply Pythonic improvements: 4. Improve code structure: 5. Improve error handling: 6. Run the tests to verify behavior is unchanged. 7. Run linting tools (ruff, flake8) to verify style compliance. ## Format ``` File: Refactorings Applied: - -> Lines Changed: -> ``` ## Rules - Never change behavior during refactoring. - Run tests after every refactoring step. - Follow PEP 8 style guidelines.