Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move tabbar lru_caches to instance level
Flake8-bugbear correctly pointed out that TabBar instances would not be reliably cleaned up because the `self` reference would be cached in the lru_caches on a couple of the methods. And the caches are on the class so they last for the whole lifetime of the process. This commit move the caches to be created per instance, instead of on the class. Other options: 1. get rid of the caches From running the benchmark tests (eg `python3 -m pytest --benchmark-columns Min,Max,Median,Rounds -k test_update_tab_titles_benchmark`) it seems like the caches can still be helpful (even though when they were introduced in qutebrowser#3122 we didn't have the config cache either) 2. use cachetools to manage our own cache instead of using lru_cache in a non-standard way I don't feel like introducing a new dependency given this change didn't end up being too offensive. 3. clear the cache whenever a window get closed That would solve the "not getting deleted issue" but flake8 would still complain :) Possibly the cache size could be reduced now that there is going to be one per window. But the aren't caching large objects anyway. Flake8-bugbear change: PyCQA/flake8-bugbear#218 Video that pointed out this way of using lru_cache: https://youtu.be/sVjtp6tGo0g
- Loading branch information