Let's say I have the following function, which takes x and y.
def calculate(x, y):
return sin(x)**3 + y
In my use case, I call the function very often but mainly change y and x only once in a while. Since my function is computationally intense I would like to speed it up. Of course, I could restructure the complete code so that nothing gets calculated multiple times, but the added speed would not justify the added complexity.
I recall there was something for exactly this but I cannot remember what it was (maybe functools or some decorator?).