Quick actions

cmd+k|ctrl+k

Navigation

Languages

bytecode

Snippet info

Language

Python

Visibility

public

Author

alexw1689

Created

2024-04-05T04:24:33.21537Z

Updated

2024-04-05T04:24:54.240623Z

import dis

def fib1(n):
    if n < 2:
        return n
    curent, next = 0,1
    while n:
        curent, next = next, curent + next
        n-=1
        
    return curent
print(fib1.__code__) # the address of the function
print(fib1.__code__.co_consts) #return tuple, constant, first
print(fib1.__code__.co_names) # all the local variable name
print(fib1.__code__.co_code) # actual bytecode
dis.dis(fib1)

a=1,2
print(a)
print(a[0])
#[0]=3

a=[1,2,3],[3,4,5]
a[0].append(4)
print(a)
print(a[0].remove(1))
print(a)

a = "hello"
print(type(a))
a = 10
print(type(a))
a = a + 1
print(id(a)) #immuable
a = [1,2,3]
print(id(a))
a.append(4)
print(a)
print(id(a)) #immuable
a =1,2,3
a = 1, [2,3], [4,5]
a[1].append(4)
print(a)
INFO