As a result of @st.cache trying to cover too many use-cases under a single unified API, it's both slow and complex.
Solution
While @st.cache tries to solve two very different problems simultaneously (caching data and sharing global singleton objects), these new primitives simplify things by dividing the problem across two different APIs. As a result, they are faster and simpler.
@st.experimental_memo
Use @st.experimental_memo to store expensive computation which can be "cached" or "memoized" in the traditional sense. It has almost the exact same API as the existing @st.cache, so you can often blindly replace one for the other:
```python
import streamlit as st
@st.experimental_memo
def factorial(n):
    if n < 1:
        return 1
    return n * factorial(n - 1)
f10 = factorial(10)
f9 = factorial(9)  # Returns instantly!
