perf issue: How to get better performance when there are a large number of elements that have binding? #4863
-
First Check
Example Codefrom dataclass import dataclass
from nicegui import ui
@dataclass
class Demo:
id:str
for _ in range(1000): # In fact, it will be more than 1000.
demo = Demo()
ui.label("null").bind_text_from(demo, "id")
ui.run() DescriptionHi everyone! I have a lot of label need to bind_text_from a dataclass. However, if a value changed, it will not change again. Thus, binding module's actively checking is not useful any more. But the checking is still runing, so it is not firendly to CPU and causes some lag. Is there a way to have it change only once and not check again after a successful update? Thanks. NiceGUI Version2.19.0 Python Version3.9.10 BrowserChrome Operating SystemWindows Additional ContextNo response |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
Hi @weinibuliu, Could you use a bindable dataclass? This would eliminate the overhead of checking the value endlessly. |
Beta Was this translation helpful? Give feedback.
-
Hi @falkoschindler ! Thank you very much for your reply. Over the past period of time, I have refactored my project to implement the Thanks again. |
Beta Was this translation helpful? Give feedback.
Strange. For me it reacts instantaneously.
Are you saying you create 200 labels per second? This can be a bit much.
ui.pagination
can help to limit the number of elements in the DOM.