파이썬 스택과 힙
-
54 - (파이썬) 메모리 구조 : 스택과 힙, 함수와 결합할 때study with Q - 파이썬 2024. 6. 15. 11:05
# 메모리 관리에서의 스택과 힙 현대적인 프로그래밍 언어에서는 자료를 크게 2가지로 구분1) 기본 자료형 (마치 내 월급처럼) 작고 간단한 것 숫자, 문자열, 불 등 (문자열은 크기가 매우 커질 수 있지만 사용적인 관점에서 기본적이라서 기본 자료형에 포함시키는 편이다.)크기가 작고 고정되어 있으므로 → (통장에) 상자에 넣어서 옆에 차곡차곡 보관해욥이렇게 기본 자료형들이 정리되어 있는 공간을 스택(stack)이라고 한다.2) 복합 자료형(우리 레오처럼) 크고 무거운 것 리스트, 딕셔너리, 객체 등 (아무래도 고양이는 액체니까) 크기가 정해져있지 않고 → 다른 창고에 보관을 하고, 이 위피를 상자에 넣어서 차곡차곡 보관해욥이렇게 객체 자료형이 저장되어 있는 거대한 창고를 힙(heap)이라고 한다. 그리..