파이썬 전역 스택
-
55 - (파이썬) 메모리 구조: global 키워드study with Q - 파이썬 2024. 6. 15. 12:25
# 전역 스택 (global stack): 파이썬은 함수를 호출할 때 함수 내부 코드를 실행하기 위해 함수 내부의 변수를 저장할 스택을 추가로 만든다. 그 중에서도 가장 외각에 있는 스택을 전역 스택(global stack)이라고 한다. ...그래서# 전역 위치에서 x, y라는 변수를 생성x = 0y = [1,1,2,3,5,8,13]def function(): # 함수 내부에서 x, y라는 변수를 생성 x = 100 y = [90, 80, 70, 60, 50] print(x) #100 print(y) #[90, 80, 70, 60, 50]function()print(x) print(y) >>>100[90, 80, 70, 60, 50]0[1, 1, 2, 3, 5, 8, 13] 그런데 만약 함수 ..