Hi all! I’ve decided to build a streamlit app in order to demonstrate how my library works and stuck with some performance issues.
I have class with several methods which return plotly object, for example:
vh = VisualisationsHandler(data1, data2)
plt = vh.build_plot(args)
Methods are slow because of preprocessing for data visualisations and I’ve thought that I could just cache results of the methods and use st.plotly_chart for fast visualisations. I came with following solution for caching method results:
@st.cache
def building_plot(vh, args):
return vh.build_plot(args)
But it didn’t improve timings much - it still takes considerable amount of time. Additionally every time I change any of the args which I pass to plotting methods all plots are redrawing.
I’ve tried to experiment with chache misses inserting st.write(f"Cache miss: expensive_computation({vh_outer}") inside the cached function and it seems that caching is working right but still very slow. I suppose that it could be connected with my class hashing.
Do you have any ideas how I can optimise that without rewriting my class?