Skip to content

Commit c4541d5

Browse files
add: garbage collection in del function modify: union of lists function
1 parent 5161f8f commit c4541d5

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

ocl.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,11 @@ def union(s,t) :
535535
def unionSequence(s,t) :
536536
res = []
537537
res.extend(s)
538-
res.extend(t)
538+
539+
# Add all elements of t that are not in s (Prevents duplicates)
540+
new_res = [x for x in t if x not in s]
541+
res.extend(new_res)
542+
539543
return res
540544

541545

oclfile.py

+11
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,24 @@
44
import pickle
55
import socket
66
import tempfile
7+
import gc
8+
79

810
from enum import Enum
911

1012

1113
def free(x):
1214
del x
1315

16+
# Garbage Collection
17+
try:
18+
gc.collect()
19+
except Exception as e:
20+
pass
21+
else:
22+
pass
23+
24+
1425

1526
class OclFile:
1627
oclfile_instances = []

0 commit comments

Comments
 (0)