Answers for "how to reduce lag in python"

2

how to lag python

Evil! Anyway...

print(9**9) is easily manageable for python. On a faily fast computer, it will 
only take a few milliseconds for the output to appear: 387420489. Check it 
against a calculator. Not bad. So let's punish our interpreter properly.

print(9**9*9) Nope. Still fast.

print(9**9*99) is still blisteringly fast. 

print(9**9*9*9*9*9*9*99**9) ... at which point, you realize that it's too much 
of a waste of your time. Python is just TOO fast. Even getting it to count on 
and on until it gets to infinity, or until your device puts itself out of use, 
probably won't actually LAG it. So let's get Mr Top-of-the-Class to calculate 
pi.





from __future__ import division
import math
from decimal import Decimal as D
from decimal import getcontext

getcontext().prec = 400
MAX = 10000
pi = D(0)

for k in range(MAX):
    pi += D(math.pow(16, -k)) * (D(4/(8*k+1)) - D(2/(8*k+4)) - D(1/(8*k+5)) - D(1/(8*k+6)))

print('Pi is' , pi)


Wait, it's still not lagging. Typical.

Conclusion: Python IS  incredibally fast and efficient. So really, throwing
your computer outside may be the best option.
Posted by: Guest on April-08-2021

Python Answers by Framework

Browse Popular Code Answers by Language