[Python] Why does my Python script run significantly slower on Windows than on macOS for the...

Discussão em 'Python' iniciado por Stack, Maio 17, 2025.

  1. Stack

    Stack Membro Participativo

    I'm running a Python script that reads a large CSV file (~500MB), performs some basic data manipulation using pandas, and writes the result back to disk. The code is exactly the same on both systems, but performance is very different:

    macOS (MacBook Air M1, 8GB RAM): ~30 seconds

    Windows 11 (Intel i7, 16GB RAM, SSD): ~2 minutes+

    I’m trying to understand what might be causing this significant slowdown on the Windows machine, especially since the hardware is arguably better.

    ✅ Verified Python version — Python 3.11.2 installed on both machines.

    ✅ Checked pandas version — Both using pandas 2.2.2 and numpy is up to date.

    ✅ Tested file location — The CSV file is stored locally on both machines (not on a network or external drive).

    ✅ Disabled antivirus — I paused Windows Defender real-time protection in case it was scanning files during runtime.

    ✅ Ran with admin privileges — No change.

    ✅ Monitored CPU and memory usage — No bottlenecks observed. CPU usage stays low on Windows, surprisingly.

    ✅ Tried WSL — Running the same script under WSL (Ubuntu) on the Windows machine reduced the runtime slightly (~1.5 minutes), but still much slower than macOS.

    Continue reading...

Compartilhe esta Página