Streamlit being bit Slow on procedural programming

This is a great tool and i have built a great dashboard using this. But what i found is that it takes time to load when you load python scripts and import its modules than putting all modules in the same main script. Could you please confirm this ?

Hi @Sandeep_Ramesh, welcome to the community!

I’m not sure I understood everything :thinking: could you maybe provide 2 small code snippets of what you’re trying to achieve and that we could try on our side ?

On my side I generally have 1 - 2 Streamlit scripts that load functions defined in other modules of a Python project, and it’s going smootly, but I may have misunderstood your case :slight_smile: .

Best,
Fanilo

from EDA import visualize as vs
if state.to_visualize and state.keyword:
        vs.plot_metrics(state.df)
        vs.plot_sentiment(state.df, state.keyword)
        plot_sentiment_timeline(state.df,state.keyword)
        vs.vis_bk_distribution(state.df, state.keyword)

the plots that i make here is comparatively slower when i do not use modules from import. these plots are for EDA purposes of the data.

Also do you have a threshold where things will start to slow down based on the size of the data we are importing. Because we are re-executing the whole python script on each re-run.

Maybe answer to this questions would help.
Any idea on the threshold of the data before it starts to slow down because it needs to load the entire pandas csv and then re-run the entire python script. ?

any suggestions for these ? maybe like a different file format to load or something ?

For code where you are loading a dataset, using st.cache will keep you from having to re-load the same dataset over and over: