Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Terminal check not cached #48

Open
gollux opened this issue Jun 15, 2023 · 1 comment
Open

Terminal check not cached #48

gollux opened this issue Jun 15, 2023 · 1 comment

Comments

@gollux
Copy link

gollux commented Jun 15, 2023

Every time a colored message is printed, the module checks again in colored output is enabled. This is unnecessarily slow. The result of the check should better be cached.

@hugovk
Copy link
Member

hugovk commented Jun 27, 2023

I wonder if something like this would work? Would it cache too often?

+from functools import lru_cache


+@lru_cache(maxsize=None)
 def _can_do_colour(
     *, no_color: bool | None = None, force_color: bool | None = None
 ) -> bool:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants