I have a function that has the following signature:
def spectrogram(signal: numpy.ndarray, sampling_frequency=16000, win_len=512, hop=256, win_type='hanning')
The function expects a numpy array on input (signal), plus number of other parameters, and outputs a numpy array. It computes spectrogram for the given audio file in order to obtain certain acoustic features. Per file, I am going to call this function multiple times, often with the same parameters, but not always. For certain features I might change the hop or win_type. I was thinking to cache the results, so that I don't run the same computations more than once. The results are valid per file. The files are going to be processes in parallel with joblib.
I was thinking to memoize the results based on the file name (which isn't a parameter that I normally would have on the function) and fields sampling_frequency, win_len, hop and win_type (i.e. NOT signal - this can be a large array and it is much more efficient to look at filename, which is unique).
How can I best memoize the results? All solutions that I have seen, cache results based on provided input; in my case I'd like to memoize based on selected fields. I am on Python 3.6.