Suppose I have following function(just an example):
a = ['apple', 'mango', 'kiwi']
b = ['apple']
def random_fucnction(a, b):
len_a = len(a)
len_b = len(b)
combined_len = len_a+len_b
diifrence = list(set(a)-set(b))
return diifrence, combined_len
in order to reduce memory usually I use del
at the end of the function:
def random_fucnction(a, b):
len_a = len(a)
len_b = len(b)
combined_len = len_a+len_b
diifrence = list(set(a)-set(b))
del len_a, len_b
return diifrence, combined_len
is there automatic way finding out unused variable and deleting them inside the function ?