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
47
48
49
50
51
52
53
54
55
56
# -m 10009
node_one = {"name": "a"}
node_two = {"name": "b"}
node_three = {"name": "c"}
node_four = {"name": "d"}
node_five = {"name": "e"}
adj = "adjacent"
node_one[adj] = [node_one, node_two, node_three, node_four, node_five]
node_two[adj] = [node_two, node_three, node_four, node_five, node_one]
node_three[adj] = [node_three, node_four, node_five, node_one, node_two]
node_four[adj] = [node_four, node_five, node_one, node_two, node_three]
node_five[adj] = [node_five, node_one, node_two, node_three, node_four]
# output {"name": "a", "adjacent": [{"name": "a", "adjacent": [..., ..., ..., ..., ...]}, {"name": "b", "adjacent": [..., ..., ..., ..., ...]}, {"name": "c", "adjacent": [..., ..., ..., ..., ...]}, {"name": "d", "adjacent": [..., ..., ..., ..., ...]}, {"name": "e", "adjacent": [..., ..., ..., ..., ...]}]}
print(node_one)
# output 2112 bytes in use; 39 refs in use
mem()
gc()
# output 2112 bytes in use; 39 refs in use
mem()
gc()
# output 2112 bytes in use; 39 refs in use
mem()
gc()
# output 2112 bytes in use; 39 refs in use
mem()
del node_two
del node_four
del node_five
del node_one
del node_three
# output 2112 bytes in use; 39 refs in use
mem()
gc()
# output 112 bytes in use; 4 refs in use
mem()
gc()
# output 112 bytes in use; 4 refs in use
mem()
gc()
# output 112 bytes in use; 4 refs in use
mem()
del adj
# output 72 bytes in use; 3 refs in use
mem()
gc()
# output 72 bytes in use; 3 refs in use
mem()
gc()
# output 72 bytes in use; 3 refs in use
mem()
gc()
# output 72 bytes in use; 3 refs in use
mem()