I've been profiling my script with cProfile
and it looks like most of the time is spent in a loop that processes a large list. Would switching to NumPy help?
How to optimize Python code for speed?
NumPy is great for numeric data, but for generic Python objects you might want to look into multiprocessing
or concurrent.futures
to parallelize the work.
Also consider using @lru_cache
if your function is called repeatedly with the same arguments.