- #1
- 2,168
- 193
I defined a simple prime function and then I append each number to an array up to 1 million and then later 2 million. In both cases, Python IDLE gives me the answer in 4 and 9 seconds respectively, but Spyder and Jupyter Notebook gave me in 12 and 24 seconds. I wonder why this happened. The time delay is doubled in each case and that's not something small.
Is Python IDLE the best in the case for performance? Or just, in this case, it gives me the best result but in other cases, I should use the other ones?
Also, I didn't run it on the PyCharm but what would be the speed of the same operation on that IDLE?
I am trying many IDLE's but I am not sure to use which one. What would be your ideas on idle on both performance and usability?
Is Python IDLE the best in the case for performance? Or just, in this case, it gives me the best result but in other cases, I should use the other ones?
Also, I didn't run it on the PyCharm but what would be the speed of the same operation on that IDLE?
I am trying many IDLE's but I am not sure to use which one. What would be your ideas on idle on both performance and usability?
Python:
import time
start=time.time()
def prime(N):
if N==0 or N==1:
return False
y=int(N**(0.5))
for i in range(2,y+1):
if N%i==0:
return False
return True
A=[N for N in range(1000000) if prime(N)==True]
end=time.time()
Time=end-start
print("Time to solve",Time,"sec")
Runtime on Pyton IDLE: 4.639 sec
Runtime on Jupyter : 9.4383 sec
Runtime on Spyder : 8.633 sec