I wonder why is the json-ing of dataframes preferred over filtering the df multiple times in respective callbacks?
.to_json and .from_json methods seem to be extremely slow and they work much worse than actually filtering the df multiple times in the respective callbacks.
Why is the approach of storing json-ed df in a hidden div advised in the first place? It is way worse than the multiple df filter.
Is there a way to share data between callbacks which is faster than .to_json, .from_json methods?
The slow performance is not (only) due to the serialization to JSON, in most cases it’s mainly due to the transfer of data between the server and the client. You can avoid it all by caching the data on the server. I made a small library to ease the pain,
but you could also implement the caching manually.
Cool. Let me know how it goes :). In short, the requires changes should be something like,
Replace the Dash object by
from dash_extensions.enrich import DashProxy, ServersideOutputTransform
app = DashProxy(transforms=[ServersideOutputTransform()]) # enable use of ServersideOutput objects
Change the Output object that stores the data to a ServersideOutput (also imported from dash_extensions.enrich)
You should then be able to save the data frame directly without serialization to JSON