Connection between streamlit and google sheets make the app considerably slow

I have a very simple web app in streamlit. It is connected with google sheets. But these two lines make my app very slow!

s=Spread(spreadsheetname,client=client)
sh=client.open(spreadsheetname)

In every interaction, the streamlit run the whole code again, that’s why these two lines create problems. How can I solve the issue?

Hi @Sinakian,

Thanks for posting!

You can use caching to avoid re-running time-consuming parts of your code.

Caroline :balloon: