I have a script that takes about 10 minutes to run on my local machine. At the beginning of the script, I have to build some pretty big lists and iterate through them to perform various cleanup functions, which creates new lists of the cleaned data. Is there a standard way to clear/preserve memory while doing this?
My initial thought was to simply reset the variable to an empty list once I am done using it:
lst = [1,2,3, toinfinity..]
clean_lst = [x for x in l if x < infinity]
lst = []
cleaner_lst = [x for x in clean_lst if x > 100]
clean_lst = []
# etc...