The following code creates a table (Tabulator) with 200 rows by 15 columns.
Then clicking the button to update the five static texts takes about 10seconds.
Any suggestions on what I could do to speed things up?
import panel as pn
import panel.widgets as pnw
import pandas as pd
import numpy as np
from random import *
df = pd.DataFrame(np.random.randn(200, 15))
tbl = pn.widgets.Tabulator(df)
sym_info1 = pnw.StaticText(value='sometext')
sym_info2 = pnw.StaticText(value='sometext')
sym_info3 = pnw.StaticText(value='sometext')
sym_info4 = pnw.StaticText(value='sometext')
sym_info5 = pnw.StaticText(value='sometext')
def b(e):
sym_info1.value = sym_info2.value = sym_info3.value = sym_info4.value = sym_info5.value = str(random())
btn = pnw.Button(name="Click me")
btn.on_click(b)
x = pn.Column(btn, sym_info1, sym_info2, sym_info3, sym_info4, sym_info5, tbl).show()
Try putting your app in a template. It speeds up things
.
import panel as pn
import panel.widgets as pnw
import pandas as pd
import numpy as np
from random import *
pn.config.sizing_mode="stretch_width"
df = pd.DataFrame(np.random.randn(200, 15))
tbl = pn.widgets.Tabulator(df, theme="site")
sym_info1 = pnw.StaticText(value='sometext')
sym_info2 = pnw.StaticText(value='sometext')
sym_info3 = pnw.StaticText(value='sometext')
sym_info4 = pnw.StaticText(value='sometext')
sym_info5 = pnw.StaticText(value='sometext')
def b(e):
sym_info1.value = sym_info2.value = sym_info3.value = sym_info4.value = sym_info5.value = str(random())
btn = pnw.Button(name="Click me")
btn.on_click(b)
x = pn.Column(sym_info1, sym_info2, sym_info3, sym_info4, sym_info5)
pn.template.FastListTemplate(
title="Tabulator slows down",
sidebar = [btn],
main = [x,tbl],
).servable()
Panel is built on Bokeh. Bokeh uses its own layout engine over the browsers layout engine because 1. Legacy reasons 2. Greater control over plots. But the layout engine can be a performance bottleneck.
If you use a template the bokeh engine can focus on smaller, individual components instead of one big complicated component (the Column here). This will speed up things.
The plan is that Bokeh 3.0 should get rid of the layout engine and just use css. That should solve some performance issues.