i am running some queries on a normal sized dataframe of 1m rows. All my calculations take 0.04 seconds but just calling Figure() consumes 0.25s. Is there any way to speed it up? Why does it take so long?
I also noticed that if i repeat Figure() calls under the first one they get executed in lighting speed instead of needing 0.25s
I am using also Dash. The crazy thing is that if i use a variable outside of the callback function like this:
fig = Figure() @callback(...) def my_callback(...) global fig .... add traces to fig return fig
It’s fast again. The strange thing is that the fig is always displaying the correct data. Why is this possible? Shouldn’t the global fig include the traces from the previous call?
app.run_server(debug=True, host="0.0.0.0", threaded=False, processes=4)
and the expected behavior is only happening when processes=1
If i do
fig = Figure() @callback(...) def my_callback(...) fig = Figure() .... add traces to fig return fig
without the def global it works and is faster as well.