Skip to content

Commit 17635d2

Browse files
authored
[고동희] 6-13주차 미션 제출 (#111)
1 parent 475c628 commit 17635d2

20 files changed

+131
-0
lines changed

8th_members/고동희/10주차.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# 10주차
2+
3+
## 싱글 프로세스 + 싱글 스레드
4+
![alt text](week_10_single.png)
5+
6+
## 싱글 프로세스 + 멀티 스레딩
7+
![alt text](week_10_multi_threading.png)
8+
9+
## 싱글 프로세스 + 멀티 스레딩 (개수 제한)
10+
![alt text](week_10_multi_threading2.png)

8th_members/고동희/11주차.md

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# 11주차
2+
3+
## Set 내부 구조 살펴보기
4+
```
5+
PyTypeObject PySet_Type = {
6+
PyVarObject_HEAD_INIT(&PyType_Type, 0)
7+
"set", /* tp_name */
8+
sizeof(PySetObject), /* tp_basicsize */
9+
0, /* tp_itemsize */
10+
/* methods */
11+
(destructor)set_dealloc, /* tp_dealloc */
12+
0, /* tp_vectorcall_offset */
13+
0, /* tp_getattr */
14+
0, /* tp_setattr */
15+
0, /* tp_as_async */
16+
(reprfunc)set_repr, /* tp_repr */
17+
&set_as_number, /* tp_as_number */
18+
&set_as_sequence, /* tp_as_sequence */
19+
0, /* tp_as_mapping */
20+
PyObject_HashNotImplemented, /* tp_hash */
21+
0, /* tp_call */
22+
0, /* tp_str */
23+
PyObject_GenericGetAttr, /* tp_getattro */
24+
0, /* tp_setattro */
25+
0, /* tp_as_buffer */
26+
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
27+
Py_TPFLAGS_BASETYPE, /* tp_flags */
28+
set_doc, /* tp_doc */
29+
(traverseproc)set_traverse, /* tp_traverse */
30+
(inquiry)set_clear_internal, /* tp_clear */
31+
(richcmpfunc)set_richcompare, /* tp_richcompare */
32+
offsetof(PySetObject, weakreflist), /* tp_weaklistoffset */
33+
(getiterfunc)set_iter, /* tp_iter */
34+
0, /* tp_iternext */
35+
set_methods, /* tp_methods */
36+
0, /* tp_members */
37+
0, /* tp_getset */
38+
0, /* tp_base */
39+
0, /* tp_dict */
40+
0, /* tp_descr_get */
41+
0, /* tp_descr_set */
42+
0, /* tp_dictoffset */
43+
(initproc)set_init, /* tp_init */
44+
PyType_GenericAlloc, /* tp_alloc */
45+
set_new, /* tp_new */
46+
PyObject_GC_Del, /* tp_free */
47+
.tp_vectorcall = set_vectorcall,
48+
};
49+
```
50+
51+
```
52+
static void
53+
set_dealloc(PySetObject *so)
54+
{
55+
setentry *entry;
56+
Py_ssize_t used = so->used;
57+
58+
/* bpo-31095: UnTrack is needed before calling any callbacks */
59+
PyObject_GC_UnTrack(so);
60+
Py_TRASHCAN_BEGIN(so, set_dealloc)
61+
if (so->weakreflist != NULL)
62+
PyObject_ClearWeakRefs((PyObject *) so);
63+
64+
for (entry = so->table; used > 0; entry++) {
65+
if (entry->key && entry->key != dummy) {
66+
used--;
67+
Py_DECREF(entry->key);
68+
}
69+
}
70+
if (so->table != so->smalltable)
71+
PyMem_DEL(so->table);
72+
Py_TYPE(so)->tp_free(so);
73+
Py_TRASHCAN_END
74+
}
75+
```
76+
1. set 객체는 삭제될 때(destruction), set_dealloc 함수를 호출한다.
77+
2. set_dealloc 함수는 가비지 컬렉터의 추적 대상에서 제외하고, 약한 참조 리스트를 클리어 하는 등의 작업을 한다.
78+
3. 약한 참조 리스트를 클리어한다고 해서, 약한 참조 리스트에 포함되어 있는 다른 객체들의 메모리가 해제되는 것은 아니다.
79+

8th_members/고동희/12주차.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# 12주차
2+
3+
## unittest 사용하기
4+
![alt text](week_12.png)

8th_members/고동희/13주차.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# 13주차
2+
3+
## pdb 실행해보기
4+
![alt text](week_13_debug.png)
5+
6+
## CProfile 실행해보기
7+
![alt text](week_13_profile.png)

8th_members/고동희/6주차.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# 6주차
2+
3+
## 프레임 객체 생성하기
4+
![alt text](week_6.png)

8th_members/고동희/7주차.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# 7주차
2+
3+
## tracemalloc 모듈 사용해서 직접 메모리 확인해보기
4+
![alt text](week_7.png)

8th_members/고동희/8주차.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# 8주차
2+
3+
## sys.getrefcount 사용해보기
4+
![alt text](week_8.png)

8th_members/고동희/9주차.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# 9주차
2+
3+
## 싱글 프로세스
4+
![alt text](week_9_single.png)
5+
6+
## 멀티 프로세스
7+
![alt text](week_9_multi.png)
8+
9+
## 결론
10+
- 싱글: 1초
11+
- 멀티: 0.48초

8th_members/고동희/main.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import instaviz
2+
3+
def hello():
4+
name = 'donghee'
5+
text = 'hello ' + name
6+
return name
7+
8+
instaviz.show(hello)
Loading
Loading
179 KB
Loading

8th_members/고동희/week_12.png

18.9 KB
Loading
86 KB
Loading
117 KB
Loading

8th_members/고동희/week_6.png

52.9 KB
Loading

8th_members/고동희/week_7.png

61.4 KB
Loading

8th_members/고동희/week_8.png

104 KB
Loading
159 KB
Loading
117 KB
Loading

0 commit comments

Comments
 (0)