Python Web - L03

Run Settings
LanguagePython
Language Version
Run Command
import dis # import dis to convert to byte code, push and pop example def fib(n): # Python 3.6 above is 2 bytes if n <=2: return 1 print(id(fib)) return fib(n-1) + fib(n-2) #dis.dis(fib) fib(5) print(fib(6)) def fib1(n): if n <= 3: return n current, second = 0, 1 while n: current, second = second, current + second #current = second; second = current + second #temp = second #second = current + second #current = temp n -= 1 return current dis.dis(fib1) print(fib1.__code__) print(fib1.__code__.co_consts) # __code__ = internal system variable print(fib1.__code__.co_varnames) print(fib1.__code__.co_code) print(dir(fib1))
Editor Settings
Theme
Key bindings
Full width
Lines