You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like to declare the input widgets in a separate cell, as shown in this example, because that allows me to
a) change the plotting code without resetting the input values,
b) reuse the same input values in multiple cells with multiple interact calls and possibly other code.
However, this approach has a big drawback: every time I run the cell with interact in it, it subscribes to the slider input event again, and old subscriptions from previous runs are not removed. This means that changing the input slider value once will rerun the plotting code once for each time I reran the cell with interact (this can be verified by observing the change in count when moving the slider one step). After n reruns, every change to the input value causes the plotting code to rerun n times.
After about 10 reruns this makes each interactive update noticeably slower and after about 40 reruns the performance becomes sluggish to the point of being practically unusable.
Note: I have a reasonably powerful desktop computer (Intel i5-13600KF CPU) and this is a fairly simple plot. On slower computers or with more complex plots you will reach these thresholds earlier.
Proposed Solution
Ideally interact widgets would automatically remove these subscriptions once they are no longer visible. I don't know how complex this would be to implement.
If that is not feasible for technical reasons then it would be nice to at least have a public API function to clear all subscriptions on an input widget (perhaps there already is something for this, but I could not find it using the existing documentation).
Additional context
Tested with ipywidgets==8.1.1, jupyterlab==4.0.11 and jupyter_server==2.12.5.
The text was updated successfully, but these errors were encountered:
Problem
Consider a simple notebook consisting of these two cells:
I would like to declare the input widgets in a separate cell, as shown in this example, because that allows me to
a) change the plotting code without resetting the input values,
b) reuse the same input values in multiple cells with multiple
interact
calls and possibly other code.However, this approach has a big drawback: every time I run the cell with
interact
in it, it subscribes to the slider input event again, and old subscriptions from previous runs are not removed. This means that changing the input slider value once will rerun the plotting code once for each time I reran the cell withinteract
(this can be verified by observing the change incount
when moving the slider one step). After n reruns, every change to the input value causes the plotting code to rerun n times.After about 10 reruns this makes each interactive update noticeably slower and after about 40 reruns the performance becomes sluggish to the point of being practically unusable.
Note: I have a reasonably powerful desktop computer (Intel i5-13600KF CPU) and this is a fairly simple plot. On slower computers or with more complex plots you will reach these thresholds earlier.
Proposed Solution
Ideally
interact
widgets would automatically remove these subscriptions once they are no longer visible. I don't know how complex this would be to implement.If that is not feasible for technical reasons then it would be nice to at least have a public API function to clear all subscriptions on an input widget (perhaps there already is something for this, but I could not find it using the existing documentation).
Additional context
Tested with
ipywidgets==8.1.1
,jupyterlab==4.0.11
andjupyter_server==2.12.5
.The text was updated successfully, but these errors were encountered: