Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
Tags
- Depth-first Search
- DP
- 중간
- 미디움
- binary search
- hash table
- linked list
- recursive
- 재귀
- 이진트리
- Array
- leetcode
- backtracking
- HashTable
- sorting
- Binary
- tree
- 문자열
- matrix
- dfs
- binary tree
- list
- math
- 쉬움
- Medium
- Python
- easy
- 리트코드
- two pointers
- string
Archives
- Today
- Total
목록Shallow copy (1)
부부의 코딩 성장 일기
얕은 복사(Shallow Copy)와 깊은 복사(Deep Copy)
얕은 복사란? 원본 객체의 요소들을 새로운 객체로 복사하지만, 내부에 있는 객체들은 참조로 복사 내부 객체는 그래서 동일한 객체를 가리키게 됨 아래 예제를 보면 단순히 list를 copy한 후, 기존 리스트(original_list)를 변경하면, 얕은 복사를 한 shallow_copy도 값이 변하게 됨. "내부 객체가 동일한 객체 - 같은 주소"를 가리키고 있기 때문! original_list = [1, [2, 3], 4] shallow_copy = original_list.copy() # 얕은 복사 후 내부 리스트의 참조는 동일함 original_list[1][0] = 99 print(original_list) # 출력: [1, [99, 3], 4] print(shallow_copy) # 출력: [1,..
Python/Fundamentals
2024. 2. 18. 19:00