Hi!
I am new using Streamlit so maybe my question is obvious, but I am designing an app that firsts loads a bunch of data from a file (what lasts a lot of time) and then I apply my functionality. The code would be something similar as below:
array_elements = load_function()
text = st.text_input("Enter text")
option = st.selectbox("Select option", ["A", "B", "C"])
if st.button("Calculate"):
do_things(text, option, array_elements)
The main problem I am facing is that every time a change is made on text_input and selectbox, the page reloads and executes again load_function, which takes a long time.
Is there a posibility for not executing again just that part of code, just doing it the first time the app is opened?
They’re conceptually simpler and much, much faster. In some of our internal tests on caching large dataframes, @st.experimental_memo has outperformed @st.cache by an order of magnitude. That’s over 10X faster!