Speed up load with 2% by improving _register_watcher
- Dominant language
- Python
- Stars
- 521
- Forks
- 86
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 35
Description
I'm on the `main` branch of Panel trying to find performance improvements. I can see that `_register_watcher` shows up spending ~8% of the time in the profiling report.

My guess is that this can be improved 25% by looking up things more efficiently and testing `in` on sets or dictionaries instead of lists.
## Reproduce
```python
import panel as pn
N=10
pn.Column(
*[pn.Row(
*[pn.pane.Markdown("Hello World") for i in range(N)]
) for i in range(N)]
).servable()
```
Run
```bash
panel serve script.py --index script --admin --profiler pyinstrument
```
Open the app 5 times and inspect the performance report.

Contributor guide
Assessment
This issue has not been assessed yet.