Quick actions

cmd+k|ctrl+k

Navigation

Languages

byte code

Snippet info

Language

Python

Visibility

public

Author

benthenirut

Created

2025-02-05T01:35:37.917194Z

Updated

2025-02-05T03:03:56.11233Z

import dis
def fib(n):
  if n<=2:
       return 1
  print(id(fib))
  return fib(n-1)+fib(n-2)
dis.dis(fib)
def fib1(n):
    if n<= 2:
        return n
    current, second = 0, 1
    while n:
        #temp = second
        #second = current + second
        #current = temp
        current, second = second, current + second # 2 tuples tuple no need ()
        n -= 1  # n= n-1
    return current
dis.dis(fib1)
print(fib1.__code__)
print(fib1.__code__.co_consts)
print(fib1.__code__.co_varnames)
print(fib1.__code__.co_code)
print(dir(fib1))
INFO