Legacy Code Refactoring

ChatGPT📝 TextDec 8, 2025zoe_prompt

About this result

Transform spaghetti code into something you're proud of. Get clean, fast, documented code — plus learn what made the old version slow.

ChatGPT Prompt

Act as a Senior Python Engineer. Refactor the provided legacy code block.

Context:

  • The current code is slow and hard to read.
  • It processes large CSV files sequentially.
  • Target environment: Python 3.12.

Requirements:

  1. Implement vectorization using Pandas where possible.
  2. Add type hinting (PEP 484).
  3. Add docstrings following the Google style guide.
  4. Handle 'FileNotFound' and 'EmptyData' exceptions gracefully.

Code to refactor: [PASTE CODE HERE]

Output format:

  • The refactored code block.
  • A bulleted list of the performance improvements made.
#development#python#code-quality

Was this prompt helpful?

5

people found this useful

Z

zoe_prompt

Shared Dec 8, 2025

Have a great prompt to share?

Submit Your Prompt