Caching expensive operations in python
Problem You have a function that takes a lot of time to execute. You need to call that function frequently, at different points in your code with the same arguments. This expensive function seems to be the bottleneck. Hopefully, after reading this post you will be able to deal with this situation and make your code work faster. Caching the output You can cache the output of the expensive function using lru_cache....