user559611
user559611

Reputation:

running python script in bash slower than running code in IDLE

I have written a python script to draw the sierpinski gasket using Tkinter and when run from the python IDLE the program takes about half the time it takes to run when run from bash. I timed the script using them time module in python. Any ideas as to why this is happening will be appreciated. thanks

Upvotes: 0

Views: 1165

Answers (2)

Rafe Kettler
Rafe Kettler

Reputation: 76945

It's because of the way you're passing it. Based on your comment on the other answer, you're using python -c, and in IDLE you're using the Run command (or something similar). I'm not aware of any performance issues with python -c, but using Run in IDLE to run somescript.py is equivalent to python somescript.py.

You really should run scripts using python -c, it's more for small snippets.

Upvotes: 2

Erick
Erick

Reputation: 751

Rafe is likely correct - you can test this out by limiting your imports and seeing if that makes a difference in startup time. I.e., if you are doing

from Tkinter import *

then change that to import only the modules you actually need. Or write a quick null program that just sets up and tears down without using anything in the package - that should run pretty close to the same in both.

Upvotes: 0

Related Questions