Fibonacci F( )

Run Settings
LanguagePython
Language Version
Run Command
import dis def fib(n): if n <= 2: return 1 print(id(fib)) return fib(n - 1) + fib(n - 2) # Display the disassembled bytecode of the function dis.dis(fib) print(id(fib(5))) def fib1(n): if n < 2: return n current, next = 0,1 while n: current, next = next, current + next n -=1 return current print(print(1)) print(fib1.__code__) #the address of the function print(fib1.__code__.co_consts) # return triple, constants, first const none, why is that ? Why tuple ? print(fib1.__code__.co_names) # all the local variable names, n is semi-local print(fib1.__code__.co_code) # actual byte code
Editor Settings
Theme
Key bindings
Full width
Lines