bretddog
bretddog

Reputation: 5519

VS Code runs python x2-3 slower than IDLE

I open a simple txt file of 16mb to display a graph with mplotlib. Running the python file in IDLE takes 7sec to display the chart. In VS Code it takes 17sec. With a 55mb file it takes 17sec and 53sec respectively.

Why is VS Code slower, and how can I get similar speed as IDLE?

Code:

import numpy as np
import matplotlib.pyplot as plt
import time as time

time, v_out, v_in = np.loadtxt('PS_SIM.txt', unpack=True, skiprows=1)

plt.plot(time, v_out, label="Vout")

#Set legends
plt.legend(loc=8)
plt.grid()
plt.xlabel("Time [s]")
plt.ylabel("V_out [V]")
plt.suptitle("V_out")

#Set scales
plt.ylim(0.95, 1.05)
plt.yticks(np.arange(0.95,1.05, step=0.01))
plt.xlim(0.0085, 0.010)

#Show plot
plt.show()

settings.json:

{
    "python.pythonPath": "C:\\Users\\<..>\\AppData\\Local\\Programs\\Python\\Python36-32\\python.exe"
}

task.json:

    "version": "2.0.0",
"tasks": [
    {
        "label": "build",
        "type": "shell",
        "command": "msbuild",
        "args": [
            // Ask msbuild to generate full paths for file names.
            "/property:GenerateFullPaths=true",
            "/t:build"
        ],
        "group": "build",
        "presentation": {
            // Reveal the output only if unrecognized errors occur.
            "reveal": "silent"
        },
        // Use the standard MS compiler pattern to detect errors, warnings and infos
        "problemMatcher": "$msCompile"
    }
]

launch.json:

 "version": "0.2.0",
"configurations": [
    {
        "name": "Python: Current File (Integrated Terminal)",
        "type": "python",
        "request": "launch", 
        "program": "${file}",
        "console": "integratedTerminal"
    },
...

Upvotes: 2

Views: 591

Answers (1)

Racerdude
Racerdude

Reputation: 74

Idle and VS Code are probably using different Python interpreters when they execute the code. When you run a Python program from within an IDE like VS Code it will use whatever interpreter you have specified in the settings of that IDE. I'm guessing Idle uses whatever is the standard Python interpreter as it's not really an IDE

Upvotes: 1

Related Questions