import time
def expensive_computation(a, b):
    time.sleep(2)  # 👈 This makes the function take 2s to run
    return a * b
a = 2
b = 21
res = expensive_computation(a, b)
st.write("Result:", res)
```
Try pressing R to rerun the app, and notice how long it takes for the result to show up. This is because expensive_computation(a, b) is being re-executed every time the app runs. This isn't a great experience.
Let's add the @st.cache decorator:
```python
import streamlit as st
import time
@st.cache  # 👈 Added this
def expensive_computation(a, b):
    time.sleep(2)  # This makes the function take 2s to run
    return a * b
a = 2
b = 21
res = expensive_computation(a, b)
st.write("Result:", res)
```
Now run the app again and you'll notice that it is much faster every time you press R to rerun. To understand what is happening, let's add an st.write inside the function:
