How to optimize calculations? (no need to do calculations on specific code)

I want to perform expensive computation and I see the documentation so it would be like this but failed every time I change variable
NameError: name ‘topics_coords’ is not defined

def topicord():
topics_coords = tmp.prepare_coords(model)
return topics_coords

what I want is when I change the variable with st.selectbox, the computation above doesn’t need to be done and I only need to retrieve the topics_coords data, now every time I change the variable the calculation starts from the beginning so the processing time becomes long

Hey @faizhalas,

Thanks for sharing your question!

Can you clarify when you want the function topicord to run? You mentioned you don’t want it to run when the st.selectbox value changes – do you want it to run when some other variable’s value change?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.