-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
46 lines (37 loc) · 768 Bytes
/
test.py
File metadata and controls
46 lines (37 loc) · 768 Bytes
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import gc
def task10():
class Thanos:
def __init__(self):
self.ref = " "
def __del__(self):
pass
class A:
def __init__(self):
pass
gc.collect()
t = Thanos()
t2 = Thanos()
t.ref = t
t2.ref = t2
a = []
b = []
p = A()
a.append(b)
b.append(a)
# gc.collect()
objects = gc.get_objects(0)
del t
del t2
del p
del b
del a
gc.collect()
survivors = gc.get_objects()
counter = 0
for elem in objects:
for cmp_elem in survivors:
if cmp_elem is elem:
print(cmp_elem)
counter += 1
return counter
print("Задача 10:", task10())